HowTo: Directory listing with ISO8601 date/time
Posted: Tue Mar 05, 2019 9:20 pm
This HowTo explains quickly how to get the full date/time information for a directory listing in the shell.
By default, "ls" on GNU/Linux (e.g. Debian, Ubuntu, etc) only gives a short view of date and time for files and folders: When a timestamp is further in the past, the time is not displayed at all anymore. Just the month and the year.
This is absolutely insufficient for a directory listing for fixity purposes.
Gladly, the developers already provided the parameter "--time-style" to control the date/time formatting
In order to provide a standard and machine-readable timestamp output, the following options for time-style are good:
The first one, "long-iso" has minute-exact accuracy, whereas the "full-iso" shows the full time information including timezone data: "+0200"
So with the following command, your directory listing will be proper:
Example output:
Have fun!
By default, "ls" on GNU/Linux (e.g. Debian, Ubuntu, etc) only gives a short view of date and time for files and folders: When a timestamp is further in the past, the time is not displayed at all anymore. Just the month and the year.
This is absolutely insufficient for a directory listing for fixity purposes.
Gladly, the developers already provided the parameter "--time-style" to control the date/time formatting
In order to provide a standard and machine-readable timestamp output, the following options for time-style are good:
- long-iso:
Example = 2018-07-23 11:35 - full-iso:
Example = 2018-07-23 11:35:55.980039161 +0200
The first one, "long-iso" has minute-exact accuracy, whereas the "full-iso" shows the full time information including timezone data: "+0200"
So with the following command, your directory listing will be proper:
Code: Select all
$ ls -la --time-style=full-iso