[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: How do I delete all files under a directory recursively(not any directory)
> How can I delete all files under one directory and all its child
> directories without deleting any of the child directories?
>
I dunno if there's really any program that could do this but a simple
script can do this
and this is it:
#! /bin/sh
fildir=`find` # Of course assuming you're in the directory where you're
gonna do this
for i in $ fildir
do
if [ -d $i ]; then
echo Skipping $i ...
else
rm $i -f # You can remove the -f option if you dont want to
forcibly remove
fi
done
You can save this script to some file (say delspecial.sh) in
/usr/local/bin or whatever and do a chmod +x
/usr/local/bin/delspecial.sh
Try getting some book on shell scripting, that should be a lot helpful!
:-)
Happy linuxing! :-)
-Suraj
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
---
Send e-mail to 'ilugc-request@xxxxxxxxxxxxxxxxxx' with 'unsubscribe'
in either the subject or the body to unsubscribe from this list.