script to sort files according to timestamp
Hi ,
I am planning to write a script to sort the directories in a directory according to the timestamp and then cd into that directory . Retrieve the file with the latest time stamp in that directory . the script so far is: #!/bin/sh a=$(ls /home/test/ab/list | wc -l) echo "number of files is $a" ls /home/test/ab/list > /home/test/ab/list/nu exec < /home/test/ab/list/nu while read line do cd $line ls -lt > test done but i dont know why it is not cding into the directory please can you tell me why. Regards, Arsha |
You could just ask for the list sorted by time:
ls -lt or, reverse sorted: ls -ltr Try 'man ls' for more options. |
All times are GMT -5. The time now is 02:26 PM. |