parent shell pid

hi folks

can any suggest me how to get a parent processid in the script if i am executing this in the script

vi myscript.sh

echo "parent shell pid"$$

sh myscript.sh

but when i am executing this i am getting a new pid(actually that is the child pid) whenever i am executing this script, so can any suggest how to get parent pid , which doesnt change any number of times i execute this script.

fine hoping for the answer

Try this:

ps -p $$ -o ppid=

Jean-Pierre.

ps -f | awk -v pid="$$" ' $2 == pid { print $3 } '
echo $PPID
1 Like

fine thanks for your suggestion