HowTo: Directory listing with ISO8601 date/time

Step-by-Step descriptions of how to do things.

HowTo: Directory listing with ISO8601 date/time

Postby peter_b » 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:
ls-dirlist_normal.png
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:
ls-dirlist_iso8601.png
Full ISO8601 formatted timestamp (including timezone offset)


Have fun! :D
  • 0

User avatar
peter_b
Chatterbox
 
Posts: 300
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Return to HowTo's

Who is online

Users browsing this forum: No registered users and 0 guests

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: No registered users and 16 guests

cron
Reputation System ©'