unix - Use watch to copy new files in directory twice a second -
i have folder (foo) want check twice second. if there new file in folder want copy second folder (foo2). want use watch , cp. using tcsh.
how this?
this trying:
touch lastchanged watch --interval=.5 'if [[ $(ls foo) ]] cp $; else echo "nothing new";fi
this seems work me. open better answers.
touch lastchecked watch --interval=.5 'if [[ $(find foo -newer lastchecked -ls -exec cp {} foo2 \; touch lastchecked; else echo "nothing new"; fi
watch checks twice second.
find looks files newer "lastchecked" file , copies files.
then touch lastchecked.
touching lastchecked allow cping when file has been updated.
Comments
Post a Comment