find only works from /root ???

Evan Leibovitch evan-ieNeDk6JonTYtjvyW6yDsg at public.gmane.org
Wed Oct 11 12:55:14 UTC 2006


Walter Dnes wrote:
> [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!?!?
>   
Hi Walter.

I think your problem is in the handling of the wildcard. When you run 
that command, the shell tries to expand the asterisk before `find` ever 
sees it. So if you have PDF files in your current directory, their names 
(not the wildcard) get passed to `find`. There are probably no PDF files 
in root's home directory -- so when you `cd` there the wildcard isn't 
expanded, and passed to `find` as you want.

Try single quotes around the filename, ie

find /home/waltdnes/ -iname '*.pdf'

That should work from any directory, forcing `find` to see the wildcard even if you have PDFs in your current directory.

HTH.

- Evan


--
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