- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Find Command Not Finding Files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2006 09:56 AM
04-11-2006 09:56 AM
Directory contents:
/ifas/bsi/setup/perm/SPFMAPCK
/ifas/bsi/setup/perm/SPFMARBL
/ifas/bsi/setup/perm/SPFMARIN
/ifas/bsi/setup/perm/SPFMARSI
Command:
find / -name SPFMA*
The results:
/ifas/bsi/setup/perm/SPFMARIN.
Only 1 file is returned.
Do not understand why the find command will not return all 4 SPFMA* files. If I use
find / -name "SPFMA*", all 4 file name will be returned.
Why does find / -name SPFMA* only return one file?
Monte Heeren.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2006 10:00 AM
04-11-2006 10:00 AM
Re: Find Command Not Finding Files
find / -name 'SPFMA*'
will do what you want because the quotes prevent the shell from expanding the metacharacter.
Also, you should avoid find from / because those can be very expensive operations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2006 03:31 AM
04-12-2006 03:31 AM
Re: Find Command Not Finding Files
You were right. There was a file in my root directory called SPFMARIN. The result of the command only looked for the file
SPFMARIN in other directories. Its like it stopped matching after if found the first match in the root directory.
I'm still confused.
When using the command:
find / -name SPFMA*
if a file matches this expression in the
root directory, the shell will stop
matching file names and will continue to
find only that file in other directories?
Monte.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2006 04:01 AM
04-12-2006 04:01 AM
SolutionThis should make it clearer:
Let's suppose that in your current working directory (it does not matter about the directories listed in the pathname list of the find command) you have the files "dogbone", "doggone", and "doghouse".
When you enter:
find / -name dog*
what the find command actually sees after the shell expands the '*' metacharacter
is:
find / -name dogbone doggone doghouse
and this,in fact, is a syntax error for find because -name expects exactly one argument.
If your current working directory only has the file "dogbone" in it then when you entered the same command find would actually see (with the same input as the first example):
find / -name dogbone
In this case, -name is supplied with exactly one argument so that it is not a syntax error but the ONLY file that fine will match is "dogbone".
Now, consider the case of
find / -name "dog*"
In this case, regardless of the contents of your current working directory, what find sees is:
find / -name dog*
but notice that now the '*' is actually supplied to find itself so that it can do the pattern match. Any file in any directory that begins with "dog" is now found.
You problem stems not from not understanding how the find command works but rather from not understanding how the shell works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2006 04:07 AM
04-12-2006 04:07 AM
Re: Find Command Not Finding Files
I understand now! Thank you for explaining it to me. I need to understand that the shell has a mind of its own!
Monte.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2006 04:08 AM
04-12-2006 04:08 AM