Bug 50490 - find does not work correctly in certain instances
Summary: find does not work correctly in certain instances
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: findutils
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Aaron Brown
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-07-31 17:29 UTC by bcling
Modified: 2007-04-18 16:35 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-12-07 00:06:01 UTC
Embargoed:


Attachments (Terms of Use)

Description bcling 2001-07-31 17:29:58 UTC
Description of problem:
find . -name *.<some extension> does not always work.

How reproducible:
Always

Steps to Reproduce:
1. find . -name *.jpg
2. ls *.jpg
3. cd ..
4. find . -name *.jpg
	

Actual Results:  find erratically produces results, depending on what the
current directory is.

Expected Results:  Should have returned the .jpg file listed in all
instances.

Additional info:

[root@localhost bcling]# ls *.jpg
2001_07_03_094633_shot.jpg
[root@localhost bcling]# find . -name *.jpg
find: paths must precede expression
Usage: find [path...] [expression]
[root@localhost bcling]# pwd
/home/bcling
[root@localhost bcling]# find . -name *.jpg
2001_07_03_094633_shot.jpg

<and lots of files in the /home/bcling/.netscape directory>

Rawhide is also affected.

Comment 1 Karl schmidt 2001-08-19 04:33:22 UTC
I can confirm that find acts buggy.  The question is whether it is find or the
file systtem.  Both Gnome and KDE file directories seem to have trouble when
files are moved keepin an acurate display.?

That beeing said the errors returned by find make no sence and should be fixed. 

Here is a capture of find failing to work as advertized - the fix was to move to
the root directory?
This really ought to be fixed as it is a core comand to the CLI. 

[root@malaysia src]# find /usr -name samba*
find: paths must precede expression
Usage: find [path...] [expression]
[root@malaysia src]# find /usr/ -name samba*
find: paths must precede expression
Usage: find [path...] [expression]
[root@malaysia src]# cd /
[root@malaysia /]# find /usr/ -name samba*
/usr/lib/linuxconf/descriptions/eng/samba
/usr/lib/linuxconf/descriptions/es/samba


Comment 2 Paul W. Frields 2001-08-31 12:28:11 UTC
The problem may actually be a syntax error.  Using the command

  find . -name *.jpg

causes the SHELL to match the *, not the find command. Therefore, in the 
submitter's example, while in the /home/bcling directory, the find command is 
evaluated by the shell to become:

  find . -name 2001_07_03_094633_shot.jpg

This will only find the single file resident in the current directory, 
obviously.  While in the / directory, the * evaluates to nothing if there are 
no actual "*.jpg" files in the / directory itself, thus the error (even if the 
error message itself is a little misdirecting).

The proper way to use find would be in this fashion:

  find . -name "*.jpg"

The double-quotes protect the * from being evaluated by the shell; rather the 
entire "*.jpg" argument is passed to the -name option of find, which is what is 
intended.

Comment 3 Tim Waugh 2001-12-07 13:54:54 UTC
Yes, this is a quoting issue.  Use:

 find -name '*.jpg'

Closing.



Note You need to log in before you can comment on or make changes to this bug.