Operating System - HP-UX
1753283 Members
5264 Online
108792 Solutions
New Discussion

Strange behavior in "find"

 
SOLVED
Go to solution
Joerg Roemmelt
Occasional Contributor

Strange behavior in "find"

Hello,

I got some little problem with the „find“ command.
Look at this action:

arw0726:/cadnc/iarchiv> find . -name 1609706_4571*
./1609706_4571p0114v0005.ideas
arw0726:/cadnc/iarchiv> cd 2008
arw0726:/cadnc/iarchiv/2008> ll 1609706_4571*
-rw-rw-r-- 1 arluzo cadnc 6080 7. Jan., 10:35 1609706_4571p0000v0002.ideas
-rw-rw-r-- 1 arluzo cadnc 6080 7. Jan., 10:42 1609706_4571p0000v0003.ideas
arw0726:/cadnc/iarchiv/2008> find . -name 1609706_4571*
find: Fehlende Verbindung
arw0726:/cadnc/iarchiv/2008>
arw0726:/cadnc/iarchiv/2008> find . -name 1609706_4571* -print
find: Fehlende Verbindung
arw0726:/cadnc/iarchiv/2008>


Why is „find“ only finding 1 file and not both?
The error should called “lost connection” in English.

If anyone need further information I will post them.

Hope someone can help.
Thx
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: Strange behavior in "find"

Hi:

If you didn't quote the argument to '-name' you have a problem. The shell will see the "*" and do file name expansion.

You need to do:

# find . -name "1609706_4571*"

If you only want files (and not directories too) returned, do:

# find . -type f -name "1609706_4571*"

Regards!

...JRF...

Rasheed Tamton
Honored Contributor

Re: Strange behavior in "find"

Hi,

You have to use the quote as SEP said.

man find (-name)

-name file True if pattern file matches the last component of the current file name. Pattern is matched according to Pattern Matching Notation for file name expansion. Pattern should be escaped (using backslash) or quoted when find is invoked from the shell, to prevent the shell from expanding any metacharacters. Pattern may contain supplementary code set characters.

Regards.
Joerg Roemmelt
Occasional Contributor

Re: Strange behavior in "find"

Thx now it all works. :)
Joerg Roemmelt
Occasional Contributor

Re: Strange behavior in "find"

Quoting the statement after -name was the answer.