If you need to find the oldest file in the directory you can use a shortcut as
-t switch Sort by the timestamp shown and tail gives you the last line. so you are able to see the oldest file.
To see newest file use
if you are willing to see long listing change the head -2 ( since long listing creates a summery line at the top of output )
Localhost> ls -t |tail -1
20100228-235312-9267-1.pdf
-t switch Sort by the timestamp shown and tail gives you the last line. so you are able to see the oldest file.
To see newest file use
Localhost> ls -t |head -1
20100228-235312-9267-1.pdf
if you are willing to see long listing change the head -2 ( since long listing creates a summery line at the top of output )
No comments:
Post a Comment