- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find command and wildcard in search path
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
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
09-21-2009 05:49 AM
09-21-2009 05:49 AM
I have a bunch of directories:
/dira/au01
/dirb/au02
/dirc/au03
/var
/usr
etc
I want to use the find command to only search in *u0* directories. I can't seem to find the correct syntax.
find *u0* -type f -name xxx -print
and it doesn't like the *u0* , are wild cards even possible in the search path?
Solved! Go to Solution.
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2009 05:54 AM
09-21-2009 05:54 AM
Re: find command and wildcard in search path
Try specifying an absolute path:
# find *u0* -type f -name xxx -print
It is useful to expose what the shell has done to your command by doing prefacing the command with 'echo', like:
# echo find *u0* -type f -name xxx -print
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2009 05:58 AM
09-21-2009 05:58 AM
Re: find command and wildcard in search path
find: cannot stat *u0*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2009 06:02 AM
09-21-2009 06:02 AM
Re: find command and wildcard in search path
> find: cannot stat *u0*
...means that 'find' can't find '*u0*' (literally).
This may reflect that you have turned off wildcard expansion. Note the difference in the following:
# set -f
# cd /
# echo v*
v*
# set +f
# echo v*
var
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2009 06:03 AM
09-21-2009 06:03 AM
Re: find command and wildcard in search path
Also you can list out multiple paths in the find command as in
find /dira/au01 /dirb/au02 /dirc/au03 /var /usr -type f -name xxx -print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2009 06:03 AM
09-21-2009 06:03 AM
SolutionI would use a nested find like this:
find / -name '*u0*' -type d -exec find {} -name '*xxx*' \; -print
The first find loops only through directories matching the pattern *u0* and for each loops again to look for files matching *xxx* (or whatever).
Regards,
Kobylka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2009 05:42 PM
09-21-2009 05:42 PM
Re: find command and wildcard in search path
echo /dir*/*u0*
This should produce all the directories you listed in the above example. It will /dira as well as /dirabcdef, and will also find /dira/abcdu0xyz. If you have a more restricted naming convention, by all means use the appropriate masking characters. For instance, if all the directories are /dira through /dirw, then use a character class to pick an exact match:
echo /dir[a-w]
Now, /dirabcd will not match, only /dira.
Similarly with the u0 directories. If the directories always start with au0, then don't use *. The * is far too inclusive. If the u0 directories are au0 through zu0, then again, use a character class. And if there is only a single number following, do this:
echo /dir[a-w]/[a-z]u0[0-9]
Note that find does not translate a simple file matching string *u0*. Instead, it will see how the shell will translate *u0*. You are supplying all the names from shell expansion -- that's why echo is your friend.
Bill Hassell, sysadmin