linux - Monitor for trigger file and copy all files in that directory -


i'm new unix scripting. sorry if question sounds stupid.
i have script copies files landingzone archive directory.

now, want write script checks test.txt file (which trigger file), if found copy files arrived before test.txt files landingzone archive. please let me know how this?

i'm mentioning script because i've couple more commands apart copying.

this should work

archive=...             # archive directory cd landingzone  if [ -f test.txt ];     find . -type f -maxdepth 1 ! -name test.txt ! -newer test.txt -exec cp {} $archive ';' fi 

explanation: if [ -f ... ]; performed if test.txt exists. call find to

  • search normal files ('-f')
  • exclude subdirectories (-maxdepth 1)
  • exclude test.txt (! -name test.txt)
  • exclude files newer test.txt (! -newer test.txt)
  • copy files found archive directory (-exec ...)

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -