- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Searching an IP Address in one of the file fro...
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
тАО12-13-2010 08:39 PM
тАО12-13-2010 08:39 PM
I have to find out one IP Address which is configured in a file. This file I'm not aware & can be placed in any directory or sub-directory in the System
OS is HPUX 11iv1.
I could not find any option in "grep" with recursive search.
Please advise.
Thanks in advance.
Vimal Upreti
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2010 09:39 PM
тАО12-13-2010 09:39 PM
SolutionYou can combine find(1) with grep(1):
find / -exec grep -e "string1" +
The "-exec ... +" allows you to search lots of files at one invocation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2010 09:48 PM
тАО12-13-2010 09:48 PM
Re: Searching an IP Address in one of the file from the whole system
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2010 01:04 AM
тАО12-14-2010 01:04 AM
Re: Searching an IP Address in one of the file from the whole system
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2010 06:28 AM
тАО12-14-2010 06:28 AM
Re: Searching an IP Address in one of the file from the whole system
Don't use the '\;' terminator for find's '-exec'. Doing so means that you spawn *one* process for *every* entity that 'find' passes along.
Instead use the "+" terminator which signals the collection and bundling of very large number of arguments into a list that is passed to one or more spawned processes.
For small numbers of arguments, you probably won't notice the impact. In the case you are using, you will not only waste time but seriously degrade your system performance if you use '\;' instead of '+'.
Dennis meant to write:
# find / -exec grep -e "string1" {} +
...and most certainly meant to only examine files (and not directories too) by writing:
# find / -type f -exec grep -e "string1" +
Regards!
...JRF..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2010 06:28 AM
тАО12-14-2010 06:28 AM
Re: Searching an IP Address in one of the file from the whole system
Don't use the '\;' terminator for find's '-exec'. Doing so means that you spawn *one* process for *every* entity that 'find' passes along.
Instead use the "+" terminator which signals the collection and bundling of very large number of arguments into a list that is passed to one or more spawned processes.
For small numbers of arguments, you probably won't notice the impact. In the case you are using, you will not only waste time but seriously degrade your system performance if you use '\;' instead of '+'.
Dennis meant to write:
# find / -exec grep -e "string1" {} +
...and most certainly meant to only examine files (and not directories too) by writing:
# find / -type f -exec grep -e "string1" {} +
Regards!
...JRF..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2010 07:13 AM
тАО12-14-2010 07:13 AM
Re: Searching an IP Address in one of the file from the whole system
Thanks a lot for your quick solution. It worked:
# find / -exec grep -e "string1" {} +
Regards.
Vimal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2010 12:34 PM
тАО12-14-2010 12:34 PM
Re: Searching an IP Address in one of the file from the whole system
If you are happy with the answers you were given, please read the following about how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
>JRF: Don't use the '\;' terminator for find's -exec.
Another problem with ";" and grep is the fact that grep won't tell you the name of the file, since there is only one. Perhaps that's why Jai added -print to the end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2010 04:45 AM
тАО12-15-2010 04:45 AM
Re: Searching an IP Address in one of the file from the whole system
> Dennis: Another problem with ";" and grep is the fact that grep won't tell you the name of the file, since there is only one. Perhaps that's why Jai added -print to the end.
That's a good point. It's probably clearer (if for whatever reason one uses the ';' terminator to process one argument at a time) to do:
# find / -type f -exec grep -e "string1" /dev/null {} \;
When 'grep' sees two file arguments it shows any matches with the file name for identification. Of course nothing will ever match the empty '/dev/null'.
Regards!
...JRF...