1833911 Members
18750 Online
110063 Solutions
New Discussion

delete some files

 
kholikt
Super Advisor

delete some files

I have lot of snmpcollect files that I wish to delete.

But I do not want to delete any files end with !

I have tried grep and all sort of thing but still can't figure out how to exclude file which end with ! sign
abc
3 REPLIES 3
Patrick Wallek
Honored Contributor

Re: delete some files

Try something like this:

# find /dir -type f ! -name "*!" -print

Do the above first to make sure you only get the files you want. If you do then you can try the command line below to remove the files:

# find /dir -type f ! -name "*!" -exec rm {} \;

T G Manikandan
Honored Contributor

Re: delete some files


# for i in `ls|grep -v "!" /home1/temp`
> do
> rm -i $i
> done



Thanks
V. V. Ravi Kumar_1
Respected Contributor

Re: delete some files

hi,
#for i in `ls -l |grep -v "!$" |awk `{print $9}'`
do
rm -i $i
done

Regards
Never Say No