Monday, August 11, 2008

script for sorting files by modification date

If you want to see files sorted by modification date in the subdirectories, you can paste below into the file for example mytest.sh, do it executable and run it with desireable directory as the argument
For example,
bash-2.05b$ ./mytest.sh /usr/local/etc
---
# cat > mytest.sh << EOF
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
FNAME=$1
find $FNAME -type f -exec ls -lt --full-time '{}' \; | awk '{print $6,$5,$9;}'
EOF
--
As a result you'll recieve date, size and pathname of all files from directory

No comments: