Q:

Shell script to cut the ps command output

How can I cut the ps command output to display one single process
$ ps -ef | grep -i httpd | grep -v grep

root     16786     1  0 Mar03 ?         00:01:02 /usr/sbin/httpd
apache   17153 16786  0 Apr09 ?         00:00:00 /usr/sbin/httpd
apache   17154 16786  0 Apr09 ?         00:00:00 /usr/sbin/httpd
apache   17155 16786  0 Apr09 ?         00:00:00 /usr/sbin/httpd
apache   17157 16786  0 Apr09 ?         00:00:00 /usr/sbin/httpd
apache   17158 16786  0 Apr09 ?         00:00:00 /usr/sbin/httpd
apache   17161 16786  0 Apr09 ?         00:00:00 /usr/sbin/httpd
apache   17162 16786  0 Apr09 ?         00:00:00 /usr/sbin/httpd
apache   17163 16786  0 Apr09 ?         00:00:00 /usr/sbin/httpd

A:

To display the main process:
ps -ef | grep 'httpd' | grep -v 'grep' | awk '$3 == 1'

(OR)
ps -ef | awk '/httpd/ && $3 == 1'

Here,
$3 - Parent PID. 
EDIT:
If you need just one line as output,
ps -ef | grep -m1 'httpd'

