- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: find command with wildcards
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
тАО11-20-2001 03:50 AM
тАО11-20-2001 03:50 AM
i'll try to write my first shell script. I search for files in a directorytree which ended with htm, html, doc or pdf. The command ls /path *.@(htm|html|doc|pdf) shows the right files, but in a wrong output. Therefor i want to use the command find. With the commandline :
find /path -type f -iname '*.htm' -printf '\n %P' i get the right output, but the wildcards like in the ls-command don't work.
Where is my problem!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2001 03:56 AM
тАО11-20-2001 03:56 AM
Re: find command with wildcards
"*.html"
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2001 03:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2001 04:08 AM
тАО11-20-2001 04:08 AM
Re: find command with wildcards
ls /path/*.@(html|html|pdf) is working for me.
I think you may have missed the second /
...BPK...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2001 04:31 AM
тАО11-20-2001 04:31 AM
Re: find command with wildcards
This should work :
find /path \( -name "*.htm" -o -name "*.html" -o -name "*.doc" -name "*.pdf" \) -print
This should also work:
find /path |grep -e "*.html" -e "*.doc" -e "*.pdf" -e "*.htm"
-raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2001 04:52 AM
тАО11-20-2001 04:52 AM
Re: find command with wildcards
In the shell the wildcard pattern (called a glob) is parsed by the shell *before* it is passed to the command, you can see this by typing set -x before running a command:
ls !(lost+found)
print !(lost+found)
In the case of you find line - as soon as you quote a CLI parameter, whether using single or double quoting then the parameter isn't checked for globs eg try:
ls '!(lost+found)'
(the difference between " and ' is variable expansion - it will be expanded when the variable is between " but not when between ')
Find, according to the manual page uses regular expressions (which are not the same as globs) - this are wrong. Find uses globs, but *not the same globs as the shell.*
The standard glob characters are:
* - match 0 or more characters
? - match exactly one character
[] - match one of the characters in the []
Korn Shell (and POSIX shell) add several other globs eg:
!() - find any filename not in the brackets
+() - find one or more filenames in the brackets
Find uses non-korn shell globs - ie only *,? and []...
The best solution for your problem is the following line:
find /path -type f \( -name '*.htm' -o -name '*.html' -o '*.pdf' -o '*.doc' \) -print
dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2001 05:07 AM
тАО11-20-2001 05:07 AM
Re: find command with wildcards
Werner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2001 05:21 AM
тАО11-20-2001 05:21 AM
Re: find command with wildcards
Since you mention that the output of 'ls' is correct, let me point out that there is a fundamental difference between 'ls' and 'find'.
While 'ls /path' will only list files or directories in /path, find will search recursively in all subdirectories within /path.
For this reason, the list of files retrieved by these two commands may differ not just in format but in content as well.
Be sure of what you are looking for before you decide to use one or the other.
Good Luck.