will it be poosile to sort the output of ls command based on timestamp of files.
Hello All,
Problem, i have some files under a directory say /home/user. i want to pick up the file which has the latest timestamp. for eg: content of the directory is something like this -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_sol -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_linux -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_hpux -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_hpia64 -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_aix -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.7_linux -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.7_hpux -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.7_hpia64 -rw-r--r-- 1 root other 0 Sep 15 11:27 3.5.0.13.0.7_aix -rw-r--r-- 1 root other 0 Sep 15 11:30 3.5.0.13.0.7_sol my requirement here is when i give command ls -lrt 3.5.0*_sol, it will return -rw-r--r-- 1 root other 0 Sep 15 11:26 3.5.0.13.0.daily_sol -rw-r--r-- 1 root other 0 Sep 15 11:30 3.5.0.13.0.7_sol from this output i want to pickup the file which is latest in term of date or time. in this case this is the one 11:30 3.5.0.13.0.7_sol is there any option in ls command itself only to list based on timestamp. Thanks, Shadman |
see the -t switch;
ls -lt ( to see fname & other items) ls -t (just filename) http://linux.die.net/man/1/ls |
All times are GMT -5. The time now is 03:10 AM. |