- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How to search a word in
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
тАО06-25-2007 07:04 PM
тАО06-25-2007 07:04 PM
Can i know what is the command to search for a word in subsequent directories.
1) I am using
find . -type f -print | grep "hi" *
but it is not working please correct me if i am wrong.
2) Also what should i do if i want to search in a particular files of subsequent directories
ex- if i wnat to search the word "hi" i only the *.cpp files
3) Cant we use xargs in HP- UNIX or is there any alternative for this.
Please suggest some solutions for the above queries.
thanks in advance
Vikram
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2007 07:20 PM
тАО06-25-2007 07:20 PM
Solution$ find . -type f -exec grep "hi" {} +
2) to find .cpp:
$ find . -type f -name "*.cpp" -exec grep "hi" {} +
3) Why would you settle using xargs when you can use -exec {} +?
Yes, you could use xargs in your original example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2007 07:21 PM
тАО06-25-2007 07:21 PM
Re: How to search a word in
1)
find . -type f -exec grep "hi" {} \+
2)
give -name "*cpp" as additional parameter to find:
find . -type f -name "*cpp" -exec grep hi {} \+
3) you can use xargs:
find . -type f | xargs grep "hi"
but beware of HP-UX find does not have -print0, thus you may have problems with Path/filenames with spaces.
rgds
HGH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2007 10:07 PM
тАО06-25-2007 10:07 PM
Re: How to search a word in
Thank you very much for the solutions.
I am able to search the word in subsequent directories using the command
find . -type f -exec grep hi \+ | more
but the problem is if i dont give more, it is crashing the terminal i think it is getting into some infinite loop.
Please suggest some solution for this.
thanks & regards
Vikram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2007 10:24 PM
тАО06-25-2007 10:24 PM
Re: How to search a word in
You could finding "hi" in binary files. Send the output to a file then vi/more the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2007 04:42 PM
тАО06-26-2007 04:42 PM
Re: How to search a word in
With -exec in find command
find ./ -type f -name "*.cpp" -exec grep -l hi {} \; | more
With xargs command
find ./ -type f -name "*.edi" | xargs grep -l 111111111 | more
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-27-2007 03:54 PM
тАО06-27-2007 03:54 PM