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

Re: I'm too stupid to use find, can someone help me out, please?



On Tue, Jul 06, 2004 at 11:30:44AM +0200, Joerg Johannes wrote:
| Am Di, den 06.07.2004 schrieb Rick Pasotto um 10:49:
| > On Tue, Jul 06, 2004 at 10:36:06AM +0200, Joerg Johannes wrote:
| <snip>
| > > This is not so clear anymore. But I think I understand that
| > > 
| > > jorg@localhost:/tmp/$ find . -type l -exec rm {};
| > > 
| > > should do what I want. But I get an error message saying
| > > 
| > > find: Missing argument for "-exec".
| > > 
| > > Huh? Why? I then started quoting the {} and the ; with backslashes and
| > > ' but without success. So, please, what am I doing wrong?
| > 
| > man pages are subtle! Notice "until an argument of consisting of ';' is
| > encountered". Arguments are separated by white space. Therefore:
| > 
| > find . -type l -exec rm {} \;
| > 
| > ought to work.
| 
| Aaargh! OK, that's it. Now that you pushed me onto it I think I got the
| point. Thanks

Note that normally ';' is interpreted by the shell and not passed to
the program.  For example :
    echo ;
vs.
    echo \;

The space may be necessary as well.  I don't recall that being
significant, but with my coding style I just always included the space
anyways.


BTW, another trick you can use is this :
    echo `find . -type l`
    rm `find . -type l`
however this only works if none of the filenames have special
characters (like whitespace) and only if the entire list of names is
shorter than the maximum command line length.  The -print0/xargs
combination is not subject to these pitfalls.

-D

-- 
The fear of the Lord leads to life:
Then one rests content, untouched by trouble.
        Proverbs 19:23
 
www: http://dman13.dyndns.org/~dman/            jabber: dman@dman13.dyndns.org

Attachment: signature.asc
Description: Digital signature


Reply to: