I'm new to Unix Scripting. Sorry if this question sounds stupid.
I have a script where it copies files from Landingzone to Archive directory.
Now, I want to write a script where it checks for test.txt file (which is like a trigger file), only if it is found then copy all files that arrived before test.txt files from Landingzone to Archive. Please let me know how to do this?
I'm mentioning this as script because I've couple more commands apart from copying.
This should work
ARCHIVE=... # archive directory
cd Landingzone
if [ -f test.txt ]; then
find . -type f -maxdepth 1 ! -name test.txt ! -newer test.txt -exec cp {} $ARCHIVE ';'
fi
explanation: thanks to if [ -f ... ]; everything is performed only if test.txt exists. Then we call find to