LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-06-2007, 05:18 PM   #1
Humbro
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Rep: Reputation: 0
problems using find


I don't get this. I write:

[sylow:~]$ find . -name *.sh -print

and I get the error message:

find: paths must precede expression
Usage: find [path...] [expression]


But if I write:

[sylow:~]$ find . -name *.pdf -print

it searches and finds all the pdf files, like I would have expected. Why won't this work with the shell scripts (ie, the .sh-files)?

Thanks.
 
Old 12-06-2007, 05:31 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,750

Rep: Reputation: 271Reputation: 271Reputation: 271
Both commands worked fine for me. Is there anything peculiar about your current working directory? Try:

echo $PWD

to check what your current working directory is.

--------------------
Steve Stites
 
Old 12-06-2007, 05:33 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
If there are files in the working directory when you execute the command, the shell will expand the *.sh argument to match the list of files. Most command don't want to see the glob patterns - the shell pre-expands such patterns and passes the pre-expanded list to the program. However, in the case of find, it evaluates the glob pattens itself, so you have to prevent the shell from doing it.

You do this either by prefixing the glob pattern special characters (* and ?) with \ backslash, or by quoting the argument. i.e. one of these
Code:
find . -name \*.sh -print
find . -name "*.sh" -print
find . -name '*.sh' -print
The fact that the pdf command worked for you suggest that you have no files matching *.pdf in the working directory when you executed the command.
 
Old 12-07-2007, 09:13 AM   #4
Humbro
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by matthewg42 View Post
You do this either by prefixing the glob pattern special characters (* and ?) with \ backslash, or by quoting the argument.
That worked like a charm
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems to execute the FIND command hpinto Solaris / OpenSolaris 2 03-28-2006 07:56 PM
Configure problems : can't find KDELIBS Crotalid Linux - Software 2 01-21-2006 11:50 PM
gcj problems 'cannot find -lz' zeppelin147 Linux - Software 0 11-17-2005 12:13 PM
Problems compiling: Can't find X includes... SAFX Mandriva 13 10-20-2004 12:08 AM
Having problems with program: cannot find -lqt-mt misfit-x Linux - General 2 01-20-2004 03:29 PM


All times are GMT -5. The time now is 06:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration