Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-06-2007, 04:18 PM   #1
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)?

Old 12-06-2007, 04:31 PM   #2
LQ Guru
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 11
Posts: 8,262

Rep: Reputation: 528Reputation: 528Reputation: 528Reputation: 528Reputation: 528Reputation: 528
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, 04:33 PM   #3
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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
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, 08:13 AM   #4
LQ Newbie
Registered: Nov 2007
Posts: 5

Original Poster
Rep: Reputation: 0
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


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 06:56 PM
Configure problems : can't find KDELIBS Crotalid Linux - Software 2 01-21-2006 10:50 PM
gcj problems 'cannot find -lz' zeppelin147 Linux - Software 0 11-17-2005 11:13 AM
Problems compiling: Can't find X includes... SAFX Mandriva 13 10-19-2004 11:08 PM
Having problems with program: cannot find -lqt-mt misfit-x Linux - General 2 01-20-2004 02:29 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:56 AM.

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