In my daily routine on solaris box, i have to read the latest file in vi. For this i have to run below 2 commands:
ls -ltr
vi filename
I get the latest file name with ls -ltr command (last file in the list) and then vi to open this file.
vi `ls -ltr|tail -1|awk -F" " '{print $9}'` (includes directory listing)
vi `ls -ltr|grep -v ^d|tail -1|awk -F" " '{print $9}'` (ignores directory listing)
or
vi `ls -ltr|tail -1|cut -d":" -f2|cut -d" " -f2` (includes directory listing)
vi `ls -ltr|grep -v ^d|tail -1|cut -d":" -f2|cut -d" " -f2` (ignores directory listing)
Tuesday, April 22, 2008
Read latest file in vi editor
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment