Skip to content
shellhacks.dev
Command Line

Show the full timestamp of files

Show the full timestamp of every file with ls -l --full-time in GNU coreutils. It prints nanosecond precision and the zone, which ls -l hides.

1 min read
Summarize in AI

ls -l shows a time that is rounded to the minute, or a year, and you need the exact modification time to compare two files.

Shell
touch -d '2026-03-05 14:09:26.123456789' stamp.txt
ls -l stamp.txt
ls -l --full-time stamp.txt
Text
-rw-r--r-- 1 root root 0 Mar  5  2026 stamp.txt
-rw-r--r-- 1 root root 0 2026-03-05 14:09:26.123456789 +0000 stamp.txt

--full-time is the same as -l --time-style=full-iso and prints the date, time to the nanosecond and the numeric offset from UTC, as in the GNU ls manual. The default format switches between a time and a year depending on whether the file is less than six months old, which is why two listings from different days can look inconsistent.

It is GNU only. The ls on macOS and BSD does not know the option, and ls -lT is the nearest equivalent there. For a value you are going to use in a script, stat -c %y file prints the same time without parsing ls output.

Share

More snippets

Command Line

List hidden files only

List hidden files only with ls -d .[!.]* in GNU coreutils 9 or any POSIX shell. The glob skips the dot and double dot entries that .* would match.

1 min read
Command Line

Count the files in a directory

Count the files in a directory with ls -A | wc -l, or with find when names may contain newlines. A plain ls -1 skips every hidden file.

1 min read
Command Line

Copy a directory including hidden files

Copy a directory with its dotfiles using cp -a src/. dst/. The usual src/* glob skips hidden files, and the dot form needs no shell option.

1 min read

Get new posts by email

One email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.