How do I sort the output of "ls" by last modified - including the date?
Check the -l
option of ls
:
ls -lt
Neat way using stat
:
stat -c '%y - %n' * | sort -t'-' -k1,1
Reverse:
stat -c '%y - %n' * | sort -r -t'-' -k1,1
%y
will give the modification time in human readable form,%n
will give file namesort
will sort the values according to only the modiication time