1822322 Members
5942 Online
109642 Solutions
New Discussion юеВ

Re: probelm whit rm

 
SOLVED
Go to solution
Jose Ramirez_6
Advisor

probelm whit rm

Hi.

I have a problem when i want erase full files of type
-rw-r--r-- 1 nsuser nsgroup 76680 28 mai 13:24 W1784107.tif

and i execute the following command.

sdmadr1:/u2/imagenes >rm ./*.tif

the system request whit the message.

sh: /usr/bin/rm: The parameter list is too long.

thank you.
JRM
jose ramirez
7 REPLIES 7
Stefan Farrelly
Honored Contributor
Solution

Re: probelm whit rm


Use find instead;

cd
find . -name "*.tif" -exec rm {} \;
Im from Palmerston North, New Zealand, but somehow ended up in London...
Helen French
Honored Contributor

Re: probelm whit rm

Try these:

# cd directroy_name
# rm *tif

OR

# find . -name "*tif" -exec rm {} \;

Use -i option if needed for confirmation !
Life is a promise, fulfill it!
Bill McNAMARA_1
Honored Contributor

Re: probelm whit rm

try

# for i in $(ls *.tif)
>do
>rm $i
>done

There must be a large number of files...

Later,
Bill
It works for me (tm)
MANOJ SRIVASTAVA
Honored Contributor

Re: probelm whit rm

Hi Jose


There seem to be lots of files adreesed by *.rif , you can use find as suggested or
find . -name "*.tif" -exec rm {} \;

should do the trick


Manoj Srivastava
PIYUSH D. PATEL
Honored Contributor

Re: probelm whit rm

Hi,

rm -i *.tif

It will ask for confirmation also

Piyush

James R. Ferguson
Acclaimed Contributor

Re: probelm whit rm

Hi:

The shell is doing filename expansion and the list is longer than allowed. A good way to circumvent this is to use 'find' and 'xargs' to process "bundles" of files at once. This is "cheaper" than using 'find's 'exec' option since a smaller number of processes are spawned:

# find . -name "*.tif"|xargs -L 500 -i rm {}

This will process 500 files at a time until the list is exhausted.

Regards!

...JRF...
Heiner E. Lennackers
Respected Contributor

Re: probelm whit rm

i think the shorts method would be:
echo ./*.tif | xargs rm


but you will have problem with it, if you have filenames with blanks or special characters in your list. then you can use:
ls -1 | grep [.]tif$ | xargs -i rm "{}"
or
find . -name \*.tif -exec rm {} \;
Be aware that the find-method will delete not only the files in the current dir, but also in all subdirs.

Heiner
if this makes any sense to you, you have a BIG problem