On Nov 12, 2007 5:13 PM, ankIT WALiA <[EMAIL PROTECTED]> wrote:
> Can anyone tell me, how to get latest created file from a folder to be
> used in shell script?
>
Try this:
getLatestFile(){
if [ $# -eq 1 ]; then
ls -tr $1 | tail -1
else
echo "usage: getLatestFile <dir>"
fi
}
ex.
$ getLatestFile ~
$ getLatestFile .
$ getLatestFile /tmp
HTH,
--
Manish
_______________________________________________
ilugd mailinglist -- [email protected]
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi
http://www.mail-archive.com/[email protected]/