[Top][All Lists]

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

Re: Metacharacters with the '-name' option in the find command

From: Andreas Metzler
Subject: Re: Metacharacters with the '-name' option in the find command
Date: Tue, 10 Jul 2012 18:56:52 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On 2012-07-10 address@hidden wrote:
> Hello,

> I do not understand metacharacters with '-name' option in the find command.

> Example:

> $ls file*
> file  file.html

> $find . -name file*
> find: paths must precede expression: file.html
> Usage: find [-H] [-L] [-P] [-Olevel] [-D 
> help|tree|search|stat|rates|opt|exec] [path...] [expression]

> Why it does not work like with the ls command ?

The shell expands file* to "file file.html" and executes "find . -name
file file.html". Find does not like two arguments for the -name

You need to quote patterns that contain metacharacters to prevent the
shell from expanding them itself.

find . -name file\*
find . -name 'file*'

cu andreas
`What a good friend you are to him, Dr. Maturin. His other friends are
so grateful to you.'
`I sew his ears on from time to time, sure'

reply via email to

[Prev in Thread] Current Thread [Next in Thread]