I am doing "ps -f" to see my process.
but I get lines that one of it represents the ps command itself.
I want to grep it out using -v flag, but than I get another process that belongs to the GREP itself :
I would like to exclude
[root@localhost ~]# ps -f
UID PID PPID C STIME TTY TIME CMD
root 15794 15792 0 13:48 pts/2 00:00:00 -bash
root 16157 15794 0 14:01 pts/2 00:00:00 ps -f
[root@localhost ~]# ps -f | grep -v ps
UID PID PPID C STIME TTY TIME CMD
root 15794 15792 0 13:48 pts/2 00:00:00 -bash
root 16160 15794 0 14:02 pts/2 00:00:00 -bash
while all I want is to get my pid line only.
or maybe you know another command that returns my pid and ppid only ?
thanks
how 'bout
echo "myPID->[$$] PPID->[$PPID]"
or for Bourne shell (courtesy of USENET comp.unix.shell ):
echo "myPID->[$$] PPID->[`ps -o ppid= -p $$`]"
xramm
October 5, 2007, 2:59am
3
yamsin789:
I am doing "ps -f" to see my process.
but I get lines that one of it represents the ps command itself.
I want to grep it out using -v flag, but than I get another process that belongs to the GREP itself :
I would like to exclude
[root@localhost ~]# ps -f
UID PID PPID C STIME TTY TIME CMD
root 15794 15792 0 13:48 pts/2 00:00:00 -bash
root 16157 15794 0 14:01 pts/2 00:00:00 ps -f
[root@localhost ~]# ps -f | grep -v ps
UID PID PPID C STIME TTY TIME CMD
root 15794 15792 0 13:48 pts/2 00:00:00 -bash
root 16160 15794 0 14:02 pts/2 00:00:00 -bash
while all I want is to get my pid line only.
or maybe you know another command that returns my pid and ppid only ?
thanks
I wonder ,Which flavor of Unix you use ? in the following example it is working:
[root@dns ~]# uname -a
Linux dns 2.6.22.5-76.fc7 #1 SMP Thu Aug 30 13:47:21 EDT 2007 i686 athlon i386 GNU/Linux
[root@dns ~]# ps -f | grep -v ps
UID PID PPID C STIME TTY TIME CMD
root 2593 2572 0 Oct04 pts/1 00:00:00 -bash
also works in HP Unix,
can you check this out:
[root@dns ~]# ps -f | grep -v ps |grep -v grep
UID PID PPID C STIME TTY TIME CMD
root 2593 2572 0 Oct04 pts/1 00:00:00 -bash