I have this small script and I was wondering if someone could tell me where I’m going wrong. It is basically watching a folder, and if a file with .php.something-else is uploaded, it should be deleted.
How do I get grep the file name?
Essentially, I want to check if FILE has an extention .php.something-else.
inotifywait -m -r --format '%w%f' -e create /samplefolder | while read FILE
do
if grep '*.php.* ; then <<-----HERE, I WANT THE FILE NAME
/bin/rm $FILE
fi
done
You don’t need grep. Check for the file’s existence and delete it:
You can use
caseto match it: