Hi,
I had to recover log files from a rescue disk, and now all the 1238 files have the same time stamp. I wanted to sort them in chronological order so that I can manage them more better. The files span from 2004-2009 and are of the form
log_102404.txt
log_020407.txt
log_010209.txt
I am trying to get a BASH script going to sort and time stamp them at the same time using the 'touch -m' option, but that did not go so well.
Code:
for f in (ls -t /file/directory)
do
# any file earlier than today
if [[ "X$f" < "Xlog_$(date +%m%d%y)" ]] # correct for ascii comparison
then touch -m $f # will need a magic sort routine here
fi
done
I can get a file_list with all the files sorted by file name, but getting the command 'touch -m | cat file_list.txt' did not work for me.
So I am a bit of stuck in the mud. Even though I can get a file list as a Perl array, but can't seem to get 'touch' to accept the file descriptors. 'touch' is complaining of indigestion "touch missing file operand."
I am now ripe for a kind suggestion.
Regards,
bufo