moving files based on time and using a counter Been a while.
I am trying to come up with some code to basically move files based on a numeric flag value, (the number can be anything, 1 to ?). The flag will represent the number of days the file should be held for. Once the time has been met, the file will be moved. So for example, if I have a file that is 14_myfile.dat then the myfile doesn't get moved until after 14 days.
Here is what I have come up with so far but it isn't quite working... yet.
flag=14
count=0
for file in `ls -l *myfile*.*`
do
count=`expr $count +1`
for fileone in `find . -type f -mtime ${count} -name "${flag}${file}"`
do
mv "$fileone" /directory/b"${fileone}".dat
done
done |