tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: $$ broken??



On Mon, 25 Mar 2013, David Laight wrote:
$ pid=$(sh -c 'ps -oppid -p $$')
$ pid=${pid#PPID }

Although some old versions of sh don't like the space in that pattern.

If you have a ps(1) newer than 2006-10-02, then:

pid=$(sh -c 'ps -o ppid= -p $$')

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index