Sort
Contents by
Date and Time
ls
-t
Letters are great, but sometimes you need to
sort a directory's contents by date and time. To do so, use
-t
(or
--sort=time
) along with
-l
; to
reverse the sort, use
-tr
(or
--sort=time
--reverse
) along with
-l
.
$
ls -latr ~/
-rw------- 8800 2005-10-18 19:55 .bash_history
drwx------ 368 2005-10-18 23:12 .gnupg
drwxr-xr-x 2760 2005-10-18 23:14 bin
drwx------ 168 2005-10-19 00:13 .Skype
All of these items except the last one were
modified on the same day; the last one would have been first if you
weren't using the
-r
option and thereby reversing the
results.
Note
Notice that you're using four options at one
time in the previous command:
-latr
. You could have instead
used
-l -a -t -r
, but who wants to type all of those
hyphens? It's quicker and easier to just combine them all into one
giant option. The long version of the options (those that start
with two hyphens and consist of a word or two), however, cannot be
combined and have to be entered separately, as in
-la
--sort=time --reverse
.
|