If there are 100 files created in a directory /data/ today from 2:00 AM to 10:00 AM
I need to move files older than 3:00 AM to a new directory /hold/
How to do that?
Also, if I have to move files between 3:00 AM to 9:00 AM, how to achieve that
If there are 100 files created in a directory /data/ today from 2:00 AM to 10:00 AM
I need to move files older than 3:00 AM to a new directory /hold/
How to do that?
Also, if I have to move files between 3:00 AM to 9:00 AM, how to achieve that
Did you consider the find
command? Applying the -mmin
twice to enclose the desired period, or the -newer
test accordingly.
How do I give the date?
find /data/ -type f -newer 11042016103500
Files are like
1.5M (1612002) Fri Nov 04 10:33:32 CDT 2016 887.txt
1.5M (1612002) Fri Nov 04 10:33:32 CDT 2016 889.txt
1.6M (1652434) Fri Nov 04 10:33:31 CDT 2016 877.txt
1.6M (1652434) Fri Nov 04 10:33:31 CDT 2016 878.txt
1.8M (1837570) Fri Nov 04 10:33:31 CDT 2016 879.txt
1.8M (1837570) Fri Nov 04 10:33:31 CDT 2016 880.txt
1.7M (1748194) Fri Nov 04 10:33:31 CDT 2016 881.txt
Did you consider to read the man-page for find
?
BTW, there is no way you can reliably find out the creation date of a file. All discussions in this thread refer to the last modification time of the file (which in your case is probably sufficient).