linux - Ordering a loop in bash -
i've bash script this:
for d in /home/test/* echo $d done
which ouputs this:
/home/test/newer dir /home/test/oldest dir
i'd order folders creation time 'oldest dir' directory appears first in list. i've tried ls , tree variations no avail.
for example,
for d in `ls -d -c -1 $pwd/*`
returns:
/home/test/oldest dir /home/test/newer dir
very close, not respect space in directory name. question, how have oldest dir on top , support whitespace?
ls -d -c $pwd/* | while read line echo "$line" done
Comments
Post a Comment