[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 10:36:06AM +0200, Joerg Johannes wrote:
> Hi everybody
> 
> I'd like to delete all symbolic links in a directory. I thought I'm
> smart and use find for that instead of doing it manually. OK. The find
> man page says (snipped):
> 
>  -type c File is of type c: l      symbolic link
> 
> So far so good.
> 
> jorg@localhost:/tmp/$ find . -type l
> 
> shows me all symbolic links. Great. Read further:
> 
>  -exec command ; Execute  command;  true if 0 status is returned.  All
>  following arguments to find are taken to be arguments to the command
>  until an  argument  consisting of `;' is encountered. The string `{}'
>  is replaced by the current file name being processed  everywhere it
>  occurs in the arguments to the command, not just in arguments where
>  it is alone, as in some versions of find.  Both  of  these
>  constructions might need to be escaped (with a `\') or quoted to
>  protect them from expansion by the shell.  The command  is  executed
>  in the starting directory.
> 
> 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.

-- 
Love is sunshine, hate is shadow, Life is checkered shade and sunshine.
-Longfellow (1819-1892)
    Rick Pasotto    rick@niof.net    http://www.niof.net



Reply to: