1834647 Members
2114 Online
110069 Solutions
New Discussion

Re: about find

 
wangxi
Occasional Contributor

about find

hi expert,
when i use the command "find" ,1, as "root", i type "find / -name abc* -print" and return the correct information,but when i goto a directory such as "/home/abc" and type "find . -name abc* -print ",the system give me a message "find: missing conjunction".
2,i su to username "abc",and type "find . -name abc* -print",it also tell me "find : missing conjunction".
and if i type the command as "find . -name 'abc*' -print", either root or user abc can recieve the correct information.
why??
7 REPLIES 7
Olav Baadsvik
Esteemed Contributor

Re: about find


Hi,

Check if you get the same error-message
if you use the whole path for the
find command:

/usr/bin/find ......

Regards
Olav
wangxi
Occasional Contributor

Re: about find

the error message is the same when i use the full path
Steven Sim Kok Leong
Honored Contributor

Re: about find

Hi,

abc* is expanded by the shell interpreter (your running shell) to the list of matching filenames in the existing directory.

Because -name only accepts only a single parameter, when abc* expands to multiple matching filenames, find returns a missing conjunction error because there are more than one parameter to -name.

The single quotes prevents abc* from being interpreted by the shell interpreter (your running shell).

find works in / without the single quotes because there are no matches for abc* in /.

Hope this helps. Regards.

Steven Sim Kok Leong
Steven Sim Kok Leong
Honored Contributor

Re: about find

Hi,

Alternatively to using single quotes, you can use the following to disable file-globbing (i.e. not interpreting * in the shell):

# set -f
# cd /home/abc
# find . -name abc* -print

Hope this helps. Regards.

Steven Sim Kok Leong
Olav Baadsvik
Esteemed Contributor

Re: about find


Hi,

Try this:

find . -name abc\* -print

Olav
T G Manikandan
Honored Contributor

Re: about find

As * is a special shell character.
It is better to use \ or single quote or double quote.

When you give it is abc* the shell misinterprets as multiply or something.
If you use quotes the shell iinterprets as one or more characters following abc.

you can use

find ./ -name abc\*
find ./ -name 'abc*'
find ./ -name "abc*"

Thanks
Carlos Fernandez Riera
Honored Contributor

Re: about find

cd /home/abc

echo abc*

You must find any file beginnig whit -.

The correct use for * in find is quoted.


find . -name "abc*" .....
unsupported