A problem with Bash script
- by c.sokun
I want to write a simple script to detect a file created by Windows virus, usually it create an .exe file with the same name as the directory it drop.
Here is the script it only work if the path name doesn't contain \n. Can someone help me fix this script please!
#!/bin/bash
if [ $# == 0 ]; then
echo ""
echo "==== Give me a directory to begin with! ===="
echo ""
exit
fi
for f in `find $1 -name '*.exe'` | do
filename=`basename "$f" .exe`
dir_name=`dirname "$f"`
current_dir_name=`basename "$dir_name"`
if [ $filename == $current_dir_name ]; then
rm -f "$f" # It can't remove file where path contain space or \n ??!!
fi
done