1833768 Members
2353 Online
110063 Solutions
New Discussion

Anybody knows why???

 
SOLVED
Go to solution
MAD_2
Super Advisor

Anybody knows why???

When running the find command, the following comes up:

$ find . -name *sh
find: missing conjunction

Anyone knows why this is happening? It runs OK in another HP-UX I am using. Environment issue maybe? I also ran as root.
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Anybody knows why???

You have to understand that -name expects exactly one argument but the shell is expanding *sh into as many filenames that match that pattern as are in your current directory. All you have to do is enclose the pattern in quotes and that will let cpio expand the pattern rather than the shell.

find . -name '*sh' will fix you.

If it ain't broke, I can fix that.
MAD_2
Super Advisor

Re: Anybody knows why???

Stephenson,

Fine, that resolved my issue, thanks, but why is it that it does work on the other system with a basically similiar structure (same directory and files in it)??? Only difference, the other runs HP-UX 11 while the one where I had trouble is 10.2
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Helen French
Honored Contributor

Re: Anybody knows why???

Hi Mynor:

The answer is, it depends on the shell you are using, the environment varibales set, the version of find etc. Normally different shells interprets/execute the wildcards (*,?) in different ways.

Read this document (TKB #AUSRCKBRC00003089), it will give you a better explanation:

http://us-support.external.hp.com/cki/bin/doc.pl/sid=ca36030e0f41f10775/screen=ckiDisplayDocument?docId=200000050417063

HTH,
Shiju
Life is a promise, fulfill it!
Bill Hassell
Honored Contributor

Re: Anybody knows why???

AS Clay mentioned, the shell treats * (and other) characters with special handling. find never sees the * unless it is escaped. On other systems, the exact same statement may run differently because filename globbing has been disabled. From the man page for ksh, POSIX shell (and even bash), the -f option controls globbing or filename expansion.

Try this:

echo *
set -f
echo *
set +f
echo *

This illustrates that the shell is replacing special characters with matching filenames as long as globbing is enabled.


Bill Hassell, sysadmin
MAD_2
Super Advisor

Re: Anybody knows why???

Thanks everyone!

The link given by Shiju is a good reference for those of you who look in here and would like a detailed explanation.
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with