- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep command help
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
Forums
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
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-30-2009 09:20 AM
тАО10-30-2009 09:20 AM
grep command help
I need to grep out a single word from a bunch of files under a directory. I also need to have the filename with it.
Under /usr/tmp I have about 100 servers with the hostname. I need to grep out specific words from each server and the output needs to give the server name and the word. and if possible i need to have the word displayed only once for each server as the word may be present multiple times.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 09:57 AM
тАО10-30-2009 09:57 AM
Re: grep command help
For running this process against 100 servers you have to run remsh to each server assuming you can do that without supplying a password.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 09:57 AM
тАО10-30-2009 09:57 AM
Re: grep command help
"/usr/tmp I have about 100 servers...."
"need to grep out specific words from each server...."
"server name and the word."
I can't tell if this will meet your requirement or not:
put your list of words in a file (let's call $HOME/pattern
cd /usr/tmp
grep -f $HOME/pattern server* | sort -u
you might have to futz with the "-w", "-i" or other flags...depending on whats actually in the file and what you want to see
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 04:05 PM
тАО10-30-2009 04:05 PM
Re: grep command help
of what you have and what you wish to do with
it. Particularly unclear:
> Under /usr/tmp I have about 100 servers
> with the hostname.
What does it mean to have a "server" under a
directory?
> [... everything else ...]
Perhaps some examples would be more helpful
than these vague and cryptic
non-descriptions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 05:57 PM
тАО10-30-2009 05:57 PM
Re: grep command help
>>> simple
# grep word * [inside the directory]
Under /usr/tmp I have about 100 servers ....... may be present multiple times.
Could not understand much perhaps you can grep out other stuffs from the above output.
Better you can use awk.
BR,
Kapil+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 07:49 PM
тАО10-30-2009 07:49 PM
Re: grep command help
>>Under /usr/tmp I have about 100 servers with the hostname. I need to grep out specific words...
- server is a physical thing. You cant keep it under /usr/tmp.
You can grep , may be you can use some regular expression, and sort it , use uniqe ,and pase it out.
If you could , put some pattern of your file here, and take some time to describe the pattern you want in the output. That will make more sense to provide some good reply.
Hth,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 11:37 PM
тАО10-30-2009 11:37 PM
Re: grep command help
Adding to what TTr said, you may want to use -w for a delimited match:
grep -l -w singleword
>Under /usr/tmp I have about 100 servers
Is this a different question?
Is this really: on 100 servers, I have /usr/tmp and ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2009 10:41 AM
тАО11-09-2009 10:41 AM