find only works from /root ???

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Wed Oct 11 12:57:35 UTC 2006


On Wed, Oct 11, 2006 at 01:40:50AM -0400, Walter Dnes wrote:
>   I have PS1 (the prompt) set to [machine][user][cwd]
> 
>   I try to find all pdf files in my account...
> 
> [m3000][waltdnes][~] find /home/waltdnes/ -iname *.pdf
> find: paths must precede expression
> Usage: find [-H] [-L] [-P] [path...] [expression]
> 
>   Alright, let's try it as root from my regular user directory...
> 
> [m3000][root][/home/waltdnes] find /home/waltdnes -iname *.pdf
> find: paths must precede expression
> Usage: find [-H] [-L] [-P] [path...] [expression]
> 
>   Now from /root...
> 
> [m3000][root][/home/waltdnes] cd
> [m3000][root][~] find /home/waltdnes -iname *.pdf
> /home/waltdnes/zz/sandvine.pdf
> /home/waltdnes/zz/google.pdf
> blah, blah, blah, bunch of files listed...
> 
>   What am I doing wrong?  Same syntax, different results!?!?

As chris said, quote yoru pattern.  Right now the shell is expanding
*.pdf for you, which means you are actually doing the command:

find /home/waltdnes -iname some.pdf someother.pdf yetanother.pdf

Since 'someother.pdf yetanother.pdf' makes no sense as arguments to
find, it figures they must be directories places too late in the command
line, so it gives you the error.

The reason it works for you when in /root rather than /home/waltdnes is
that there are no pdf files in /root, so the shell can't expand the
*.pdf, and hence leaves it alone (giving the same result as it if was
quoted).

--
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list