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:~#
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