- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: unexpected behaviour with find command.
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
Discussions
Discussions
Forums
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
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
тАО10-22-2002 06:43 AM
тАО10-22-2002 06:43 AM
When i search for *.ksh and *.sh files from my home directory in another directory the result is as expected but when i do the same search from one of the sub-directory in my home directory it gives no result. However if i search for full filename (Eg. test1.ksh) it just works fine.
Depicted below is the problem in commands.
#pwd
/home/users/rajeev
#find /home/prod \( -name *.ksh -o -name *.sh \)
find: cannot open /home/prod/test1
/home/prod/test/test1.ksh
/home/prod/test/test_test1.ksh
#cd sub
#pwd
/home/users/rajeev/sub
#find /home/prod \( -name *.ksh -o -name *.sh \)
find: cannot open /home/prod/test1
Reports nothing.
#find /home/prod -name test1.ksh
/home/prod/test/test1.ksh
#
However "ls -ltR /home/prod" from this sub-directory works fine.
Any help in this case would be appreiciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2002 06:50 AM
тАО10-22-2002 06:50 AM
SolutionThe problem is that shell expands meta characters BEFORE executing commands, so *.ksh is expanded if possible into current list of .ksh files if they exist in current dir before executing find. You should better use :
#find /home/prod \( -name \*.ksh -o -name \*.sh \)
or
#find /home/prod \( -name '*.ksh' -o -name '*.sh' \)
Juste to avoid expansion ...
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2002 06:57 AM
тАО10-22-2002 06:57 AM
Re: unexpected behaviour with find command.
'*.ksh' and '*.sh'. This is a good practise to follows whenever you use the find command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2002 06:57 AM
тАО10-22-2002 06:57 AM
Re: unexpected behaviour with find command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2002 07:06 AM
тАО10-22-2002 07:06 AM
Re: unexpected behaviour with find command.
I'd add that you should escape-out the PERIOD also:
find /home/prod -type f -name "*\\.ksh" -o -name "*\\.sh"
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2002 07:07 AM
тАО10-22-2002 07:07 AM
Re: unexpected behaviour with find command.
find /tmp -type f -name "*\.ksh" -o -name "*\.sh"
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2002 07:12 AM
тАО10-22-2002 07:12 AM