[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: is there a way to use find and rm together?



On Tue, Mar 13, 2001 at 10:44:18PM +0100, Martin W?rtele wrote:
> hi,
> 
> we have ftp users in home/ftpusers and we disabled shell acces for them.
> now we have .bash* files in every user directory under /home/ftpusers.
> 
> is there a way to use something like 
> find /home/ftpusers -name .bash* | rm
> unfortunately this was what i hoped that could work but i only get 
> rm: too few arguments.
> 
> i think this is because rm gets every file followed by newline from find.
> so if i use 
> find -name .bash* -print0
> i get the list without newlines but if i use
> find -name .bash* -print0 | ls 
> i get the contents of the current directory.
> 
> any ideas how to solve this problem?

xargs.

find /home/ftpusers -name .bash\* | xargs rm

For a more secure method (ie, to deal with spaces and other junk):

find /home/ftpusers -name .bash\* -print0 | xargs -0 rm

-- 
CueCat decoder .signature by Larry Wall:
#!/usr/bin/perl -n
printf "Serial: %s Type: %s Code: %s\n", map { tr/a-zA-Z0-9+-/ -_/; $_ = unpack
'u', chr(32 + length()*3/4) . $_; s/\0+$//; $_ ^= "C" x length; } /\.([^.]+)/g; 



Reply to: