ppidi=4 [ $(uname) = 'Cygwin ] && ppidi=1 ... pid=$(ps -l -p $pid | grep -v PPID | \ perl -ane 'print $F[$ARGV[0]]' $ppidi);