HI
I have folder in home dir.
/home/kpp/07222013
/home/kpp/07212013
/home/kpp/07202013
Output :--
/home/kpp/07222013
Just find latest date
HI
I have folder in home dir.
/home/kpp/07222013
/home/kpp/07212013
/home/kpp/07202013
Output :--
/home/kpp/07222013
Just find latest date
Does the name correspond to the date of last modification?
Would
ls -t | head -n 1
work ?
NO Base on modification !!!!
I want base on date !!!!
if filename = mofication date, try:
ls -1d /home/kpp/* | awk -F"/" '$0>a[$0]{a[$0]=$0} END {print a[$0]}'
Try:
ls /home/kpp/* | awk -F/ '{d=substr($NF,5,4) substr($NF,1,4)} d>m{f=$0; m=d} END{print f}'
or
cd /home/kpp
ls | awk ...
The latter will avoid line length limitations...
Alternative with sort:
ls /home/kpp/* | sort -k1.5 -k1.1,1.2 -k1.3,1.4 | tail -n 1