I need to write a script that copies files from one directory to another that were created after "today 6:30". This script will be NOT be ran at the same time each day.
any help is appreciated.
I need to write a script that copies files from one directory to another that were created after "today 6:30". This script will be NOT be ran at the same time each day.
any help is appreciated.
Use the touch command to create a file with the appropriate date/time.
touch -t datetime touchedfile
Then use the find command with the -newer option to locate the list of
files.
find ./firstdirectory -newer touchedfile -exec cp {} ./otherdirectory \;
The "find" command includes a "-newer" clause, so you can select files based on the age of a reference file. So then, all you must do is create a reference file with the correct date.
REF=.tmp.$$
touch -t $(date +%m%d)0630 $REF # today at 630 AM
find . -newer $REF -exec cp {} $TARGETDIR \;
rm -f $REF