Reputation: 6305
I'm parsing some information from ps -ef |grep process but it always displays in the output of grep the last line which is the grep itself. How can I get the output of grep without the last line? The output looks like that:
root@itaig-lt:~# ps -ef |grep gnome-terminal
itaig 3307 2306 0 09:37 ? 00:00:00 /bin/sh -c gnome-terminal
itaig 3308 3307 0 09:37 ? 00:01:58 gnome-terminal
root 7055 5047 0 13:37 pts/10 00:00:00 grep --color=auto gnome-terminal
root@itaig-lt:~#
Upvotes: 1
Views: 1117
Reputation: 289645
You can do two things:
Grep exluding the grep
itself:
ps -ef |grep gnome-terminal | grep -v grep
or add a string condition that is not matched by this grep
(see explanation):
ps -ef |grep [g]nome-terminal
Upvotes: 1
Reputation: 58788
Try searching for something which won't match the grep
command line:
ps -ef | grep [g]nome-terminal
Upvotes: 2