- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep the string only, not including grep comma...
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
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
тАО07-17-2003 11:33 AM
тАО07-17-2003 11:33 AM
grep the string only, not including grep command itself
Ex, ps -ef | grep vhand
two line output:
............vhand
............grep vhand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 11:36 AM
тАО07-17-2003 11:36 AM
Re: grep the string only, not including grep command itself
# ps -ef | grep vhand | grep -v grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 11:40 AM
тАО07-17-2003 11:40 AM
Re: grep the string only, not including grep command itself
# ps -ef|grep vhand|grep -v "grep vhand"
...is your direct answer
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 11:45 AM
тАО07-17-2003 11:45 AM
Re: grep the string only, not including grep command itself
...however, if you are looking for a process(es) by name, a better way is to leverage the XPG4 (UNIX95) option to select the process by its basename and display the data you want. FOr instance:
# UNIX95= ps -C vhand -o args,pid,ppid,sz,comm
To eliminate the headings from 'ps':
# UNIX95= ps -C vhand -o args,pid,ppid,sz,comm|awk '/NR>1/'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 11:48 AM
тАО07-17-2003 11:48 AM
Re: grep the string only, not including grep command itself
I am attaching it. Usage is psg
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 01:10 PM
тАО07-17-2003 01:10 PM
Re: grep the string only, not including grep command itself
Another alternative to the "| grep -v grep" extension is to enclose the first character of your grep string inside [] - basically, this turns the command into a regular expression.
For example:-
$ ps -ef | grep vhand | grep -v grep
can also be written as:-
$ ps -ef | grep [v]hand
This is a quick and easy alternative when entering the command interactively, but the "| grep -v grep" is far easier to use within shell scripts, especially if the grep string is a substituted variable.
Rgds,
Paul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 01:31 PM
тАО07-17-2003 01:31 PM
Re: grep the string only, not including grep command itself
Do:
ps -ef |grep -v grep | grep vhand
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 02:20 PM
тАО07-17-2003 02:20 PM