1833883 Members
1811 Online
110063 Solutions
New Discussion

Re: rm command

 
viks
Advisor

rm command

dear all..i have my /tmp file system which has plenty of small files.so while rebooting the cleanup of /tmp doesnt happen.when i manually give rm * , it give parameter is too long.how do i delete the files in /tmp.now i have to manually delete a set of matching files using *..like abc*.* and so on.somewhere i found thati have to set mode=clean.even this didnt workout..any experience on this ...thanks in advance to all
regard
9 REPLIES 9
Deepak Extross
Honored Contributor

Re: rm command

see man xargs.
There are some examples given there.
Michael Tully
Honored Contributor

Re: rm command

Hi,

Your problem stems from only being able
to remove 256 files in one go.

My workaround, to remove files more than
three days old:

# find /tmp -mtime +3 -print | xargs rm

There is a kernel limit for this, I'll try
to find what you can do to fix this problem.

Michael
Anyone for a Mutiny ?
Deepak Extross
Honored Contributor

Re: rm command

Hi again,
Here's the syntax you need:
ls | xargs -p -l | xargs rm -i

Hope this helps.

Just be sure of what you want to delete before you do this!
Tom Geudens
Honored Contributor

Re: rm command

Hi,
Well, you can make this very complicated, but the following script is the easiest form :
#!/usr/bin/sh
for vFile in $(ls *abc*)
do
rm -i $vFile
done

Save the script, chmod 775 script, cd to /tmp
and execute the script.
Replace the "ls *abc*" with the command you want. If you're sure it works, remove the "-i" option from the rm command.

Regards,
Tom Geudens
A life ? Cool ! Where can I download one of those from ?
S.K. Chan
Honored Contributor

Re: rm command

Change the kernel parameter "large_ncargs_enabled" to 1 (ie: enable it). That will increase your limit. You can use SAM to change it or command line method .. as such ..

# cd /stand/build

# /usr/lbin/sysadm/system_prep -s system
==> creates an editable kernel file
# vi system
==> add this line ..
large_ncargs_enabled 1
# /usr/sbin/mk_kernel -s ./system
==> creates the test kernel "vmunix_test"
# mv /stand/system /stand/system.prev
# mv /stand/vmunix /stand/vmunix.prev
# mv /stand/build/system /stand/system
# mv /stand/build/vmunix_test /stand/vmunix
# shutdown -ry 0
Steven Sim Kok Leong
Honored Contributor

Re: rm command

Hi,

# cd /tmp/test
# for i in `ls`;do rm -f $i;done

Tested it works where rm * failed.

Hope this helps. Regards.

Steven Sim Kok Leong
Justo Exposito
Esteemed Contributor

Re: rm command

Hi,

Try this,

for i in ls
do
rm $i
done

Very simple...

Hope this help,

Justo.
Help is a Beatiful word
Carlos Fernandez Riera
Honored Contributor

Re: rm command

If you want to remove all files from /tmp....

Why not use:

umount /tmp
newfs /dev/vg00/rlvolxxx
mount /tmp


faster, cleaner, and ... excessive?
unsupported
Nico van Royen
Frequent Advisor

Re: rm command

One other option.. just one word of caution.. be sure to be where you are in the filesystem.. (as always, when using root)...

root@tm4xm1a> ll | wc
6160 55433 548164
root@tm4xm1a> pwd
/var/tmos/logs/tap/eadir/fs/ANTKPN1A
root@tm4xm1a> date;find . -exec rm -f {} \; ; date
Thu Apr 18 13:49:02 METDST 2002
rm: cannot remove .. or .
Thu Apr 18 13:50:08 METDST 2002
root@tm4xm1a> ll | wc
1 2 8
root@tm4xm1a>

You might want to leave out the date commands... these was just there to see how long it would take to erase the 6160 files present.
If all else fails, try reading the manual...