unix - Shell Script that monitors a folder for new files -


i'm not pro in shell scripting, thats why ask here :).

let's got folder. need script monitors folder new files (no prefix name of files given). when new file gets copied folder, script should start. has second script processed file file should deleted.

i hope can give me ideas on how achieve such script :)

thank in advance. thomas

try this:

watcher.sh:

#!/bin/bash if [ -z $1 ];     echo "you need specify dir argument."     echo "usage:"     echo "$0 <dir>"     exit 1 fi  while true;     in $(ls -1 $1/* 2>/dev/null);             otherscript $a && rm $a #calls otherscript file argument , removes if otherscript returned non-zero     done     sleep 2s done 

don't forget make executable

chmod +x ./watcher.sh 

call with:

./watcher.sh <dirname> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -