96

How to sort the files according to the time stamp in unix? I need to sort the files and also based on time they created.

Gustavo Straube
  • 3,744
  • 6
  • 39
  • 62
Srihari
  • 2,509
  • 5
  • 30
  • 34

2 Answers2

176

File modification:

ls -t

Inode change:

ls -tc

File access:

ls -tu

"Newest" one at the bottom:

ls -tr

None of this is a creation time. Most Unix filesystems don't support creation timestamps.

ninjalj
  • 42,493
  • 9
  • 106
  • 148
  • 4
    Actually, many *nix filesystems do support creation timestamp… it's just not cross-platform. On FreeBSD and OS X, it's generally only available on native BSD filesystems (including HFS+ on OS X); it's called "file creation time", and `ls -U` sorts by it. On Linux, it's available on most filesystems that support it (even including NTFS), but it's called "birth time", and you have to sort manually. – abarnert Nov 06 '14 at 05:02
20

Use -t on ls. e.g:.

ls -tr

or

ls -ltr
linuts
  • 6,608
  • 4
  • 35
  • 37