![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Moving Files | iAm4Free | Shell Programming and Scripting | 5 | 03-28-2007 05:13 AM |
| moving between vi files | aya_r | Shell Programming and Scripting | 2 | 08-23-2005 05:36 AM |
| Moving specific data between databases | lloydnwo | UNIX for Advanced & Expert Users | 2 | 10-01-2004 09:09 AM |
| moving files ?? | rocker40 | UNIX for Dummies Questions & Answers | 9 | 11-09-2003 08:36 PM |
| moving only files... | sskb | UNIX for Dummies Questions & Answers | 12 | 11-19-2001 03:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Moving specific files
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 |
|
|||||
|
Quote:
|
|
|||||
|
Quote:
Code:
archive=/home/quarantine
cd /home
find . -user root -perm 0400 -type f |
while IFS= read -r file
do
dir=${file%/*}
mkdir -p "$archive/$dir"
mv "$file" "$archive/$dir"
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|