- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- The usage of find
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
тАО08-12-2002 02:57 AM
тАО08-12-2002 02:57 AM
The usage of find
When I used the command as below:
$find . -name "*.c" -o "*.cpp"
All C and CPP files were listed.
However while an extra option "-exec" was appended,only the CPP files appeared.
$find . -name "*.c" -o "*.cpp" -exec ls {} \;
Could you please give some comments?Thanks.
Regards
Jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 03:04 AM
тАО08-12-2002 03:04 AM
Re: The usage of find
This could be due to the syntax of your first find only looking for *.c files and ignoring the second option.
Try the following:
find . -name "*.c" -o -name "*.cpp" -exec ls -l {} \;
Kev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 03:07 AM
тАО08-12-2002 03:07 AM
Re: The usage of find
find . -name "*.c" -o "*.cpp" | xargs ls
or
find . \( -name "*.c" -o "*.cpp\) -exec ls {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 03:09 AM
тАО08-12-2002 03:09 AM
Re: The usage of find
Try this:
find . -name "*.c" -exec ls {} \; -o -name "*.cpp" -exec ls {} \;
Hope this helps.
-deepak.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 03:12 AM
тАО08-12-2002 03:12 AM
Re: The usage of find
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 03:18 AM
тАО08-12-2002 03:18 AM
Re: The usage of find
See man
Format is
find . \( -name '*.c' -o -name '*.cpp' \) -exec ls {} \;
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 03:20 AM
тАО08-12-2002 03:20 AM
Re: The usage of find
by "grouping" them in parens you tell find to locate either a "*.c" file OR "*.cpp", then when a result is found execute the command in "-exec".
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 03:40 AM
тАО08-12-2002 03:40 AM
Re: The usage of find
you may use a pipe to xargs as this would speed up the output.
find . -name "*.c" -o "*.cpp" | xargs ls
if the list is too long for "ls" use the -l
man xargs.
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 04:00 AM
тАО08-12-2002 04:00 AM
Re: The usage of find
find . \(-name "*.c" -o "*.cpp"\) -exec ls {} \;
Regards,
Trond
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 04:25 AM
тАО08-12-2002 04:25 AM
Re: The usage of find
Many thanks for your suggestion.
Now it works correctly as we wish.
There or more formats:
$cd prog
$ls
c-file perl shell
$ls c-file/
1.tar megaco now.tar src1 src3 src5
first.c now second.cpp src2 src4 telnet
$find . -name "*.c" -exec ls {} \; -o -name "*.cpp" -exec ls {} \;
./c-file/src1/test1.c
./c-file/src1/test2.c
./c-file/second.cpp
./c-file/first.c
$find . \( -name '*.c' -o -name '*.cpp' \) -exec ls {} \;
./c-file/src1/test1.c
./c-file/src1/test2.c
./c-file/second.cpp
./c-file/first.c
$find . \( -name "*.c" -o -name "*.cpp" \) -exec ls {} \;
./c-file/src1/test1.c
./c-file/src1/test2.c
./c-file/second.cpp
./c-file/first.c
$