>>>>> "Zhasper" == Zhasper  <[EMAIL PROTECTED]> writes:

Zhasper> On 04/07/07, Rick Welykochy <[EMAIL PROTECTED]> wrote:
>> Amos Shapira wrote:
>> 
>> > On 04/07/07, Rick Welykochy <[EMAIL PROTECTED]> wrote: >> ls -R
>> <somefile> >> currently will not list <somefile> unless it is a
>> directory.
>> >
>> > $ ls --version > ls (GNU coreutils) 5.97 > ...  > $ ls -lR x >
>> -rw-r--r-- 1 user group 177 2007-06-29 15:52 x
>> >
>> > "x" is a regular file and ls lists it. What version of ls(1) are
>> you using?
>> 
>> Mea culpa.
>> 
>> ls -R <somefile>
>> 
>> will not list <somefile> in subdirectories, i.e.
>> 
>> $ ls -lR somefile -rw-r--r-- 1 rick rick 0 2007-07-04 20:04
>> somefile
>> 
>> $ find . -name somefile ./tmp/somefile ./somefile

Zhasper> <pedant>

Zhasper> In that circumstance, there's a way to do it with just ls:

Zhasper> spindle:~/tmp polleyj$ ls -lR */somefile somefile -rw-r--r--
Zhasper> 1 polleyj polleyj 0 Jul 4 21:20 hello/somefile -rw-r--r-- 1
Zhasper> polleyj polleyj 0 Jul 4 21:20 somefile

Zhasper> it doesn't scale though; for the general case, find is more
Zhasper> useful, as you've said.  </pedant>

Zhasper> Regarding the original question, I second your suggestion:

Zhasper> find . -name "<junkfile>" -exec rm {} \;

Zhasper> However, I offer the caveat that it will file if there are
Zhasper> special characters (particularly " ") in the filename. As a
Zhasper> more robust (but more heavyweight, more forking, more cycles,
Zhasper> more ram (but - the amounts we're talking about are trivial,
Zhasper> except in extreme cases - just something to be aware of for
Zhasper> the odd times when this fails because you hit one of the
Zhasper> extreme cases)):

Zhasper> find . -name "<junkfile>" -print0 | xargs -0 rm


Actually lighter weight, less forking less execing, because this
version runs two procsses only, rather than a new invocation of rm for
each file found.

--
Dr Peter Chubb  http://www.gelato.unsw.edu.au  peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au           ERTOS within National ICT Australia
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to