HowTo: Directory listing with ISO8601 date/time

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 383
Joined: Tue Nov 12, 2013 2:05 am

HowTo: Directory listing with ISO8601 date/time

Post by peter_b »

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:
Normal listing with default formatting.
Normal listing with default formatting.
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 :D
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
Both provide an ISO8601-formatted timestamp, but in different forms:
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
Example output:
Full ISO8601 formatted timestamp (including timezone offset)
Full ISO8601 formatted timestamp (including timezone offset)
Have fun! :D
Post Reply