Hello, I am trying to move specific files to a specific folder. I have a virus script that runs and quarantines the files by changing the ownership to -r--------. This has worked fine but I am wanting to actually move the infected files to a folder called quarantine. I have came up with a basic script but it does not seem to be working properly. I am doing a "find" on the ownership specified above, which is also working fine. I am stuck on the part of moving the files once they have been found. Any help or suggestions is greatly appreciated.
#!/bin/sh
archive=/home/quarantine
cd /home
find . -user root -perm 0400 -type f | while read file; do
dir=`dirname "$file"`
mkdir -p "$archive/$dir"
mv $file "$archive/$dir"
done
Except that the OP indicated the use of /bin/sh and didn't give an indication of the OS. In this case I would err on the side of caution and assume the use of the bourne shell, not a POSIX shell.