Inotifywait shell script help - subdirectory depth
I have inotify tools installed on Ubuntu Server 10.04. I have a script that I want to set up to monitor directories recursively and it starts at boot. This isn't the actual script, just an example. It watches a directory recursively and when an event is triggered copies the file to a destination directory, but only if it's extension is ".txt". How could I modify this to watch recursively, but say up to 4 subdirectories deep?
inotifywait -m -r --format '%w%f' -e moved_to -e create $WATCHED_DIR | while read FILE ; do
if [[ "$FILE" == *".txt" ]] ; then
cp -p "$FILE" "$DEST_DIR"
Last edited by warensemble; 02-21-2013 at 10:14 AM.
Reason: wanted to notate this is for shell scripting