Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function log {
- echo "[`date +%y/%m/%d-%H:%M:%S`] $1" | tee -a $LGMLOGFILE
- }
- log "Starting inotitywait infinite loop"
- inotifywait --format "%f %e" -me close_write,moved_to,moved_from,delete,delete_self $FOLDERWATCHED | while read LINE
- do
- log "processing $LINE..."
- set -- "$LINE"
- IFS=" "; declare -a Array=($*)
- FILE="${Array[0]}"
- EVENT="${Array[1]}"
- FILENAME=${FILE%.*}
- FILEEXT=${FILE##*.}
- IFS=""
- # select by file extension
- case $FILEEXT in
- txt)
- # do something
- ;;
- map)
- # do another stuff
- ;;
- *)
- log "nothing to do with $FILE"
- ;;
- esac
- done
- log "Script finisched"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement