AlaskanWolf
06-22-2003, 02:29 AM
I want to do a server wide deletion, but not sure how to go about it.
I want to delete every index.* file that has 123xxx123 in it, does anyone know of a easy way to get this done?
(primary partion is /home)
Alareach
06-22-2003, 03:08 AM
Try:
rm -rf *index.*123***123*
I am not sure if you used the xxx as a wildcard (means anything) or not. If so use the above.
Regards
Eric Lim
06-22-2003, 03:51 AM
site=`find /home -name index.*`
for II in $site; do
file=`grep 123xxx123 $II`
if [ -n "$file" ]; then
echo "Found 123xxx123 at $II"
rm -f $II
echo "File $II deleted"
fi
done
Hope this helps.
Edited command rm -f: Great suggestion cyansmoker. I am just gotten used to rm -rf everytime I am deleting files. :D
cyansmoker
06-22-2003, 04:43 AM
Just a comment; nice script, Cyberservers, however I'd replace 'rm -rf' with 'rm -f'
No need to add the extra risk of erasing a whole directory tree if he makes a mistake while copying your script ;)
darksoul
06-22-2003, 05:44 AM
find /home -name "index.*" -print|xargs grep -l 123xxx123|xargs rm
cyberlot
06-22-2003, 10:46 AM
Originally posted by cyansmoker
Just a comment; nice script, Cyberservers, however I'd replace 'rm -rf' with 'rm -f'
No need to add the extra risk of erasing a whole directory tree if he makes a mistake while copying your script ;)
Hahaha yea, I had a friend that had a hard time typing, so he did this more then once..
His solution, He built a bash script around rm that looked for the -f and gave him a warning before proceeding to delete everything..
Sort of smart, I always thought rm should have like a -c ( confirm ) then Every action required a one time confirm, unless you have a -c
AlaskanWolf
06-22-2003, 01:32 PM
thanks all, i will give the bash script a try along with the others :)
AlaskanWolf
06-22-2003, 01:56 PM
ok, that worked thanks
now, not sure if this can be done or not. I want to copy index.* from /backupsys/alluserdirectorys)/public_html/ to /home/(allusersdirectorys)/public_html/
is this possible?