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

<pedant>

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

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

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

Regarding the original question, I second your suggestion:

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

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

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


--
There is nothing more worthy of contempt than a man who quotes himself
- Zhasper, 2004
--
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