Thursday, April 22, 2010

Sorting creation date within ls

When trying to find a file/folder in Linux filesystem using the ls command and we want to get when the file/folder is created and which file is the most recent to be listed first, we can basically use the -lUr options to get the exact output that we intend. Below is an example of the command in work.

-l (The lowercase letter ``ell''.) List in long format. (See
below.) If the output is to a terminal, a total sum for all the
file sizes is output on a line before the long listing.


-U Use time of file creation, instead of last modification for sort-
ing (-t) or long output (-l).


-r Reverse the order of the sort to get reverse lexicographical
order or the oldest entries first (or largest files last, if com-
bined with sort by size


jeff-iMac:~ jeff$ ls -lUr
total 0
drwxr-xr-x+ 5 jeff staff 170 Nov 20 12:46 Sites
drwxr-xr-x+ 5 jeff staff 170 Jun 19 2009 Public
drwx------+ 4 jeff staff 136 Nov 20 12:46 Pictures
drwx------+ 4 jeff staff 136 Jun 19 2009 Music
drwx------+ 3 jeff staff 102 Jun 19 2009 Movies
drwx------+ 29 jeff staff 986 Jun 19 2009 Library
drwx------+ 4 jeff staff 136 Jun 19 2009 Downloads
drwx------+ 4 jeff staff 136 Jun 19 2009 Documents
drwx------+ 4 jeff staff 136 Jun 19 2009 Desktop

I hope this helps!

No comments:

Post a Comment