On Mon, Nov 29, 2010 at 11:47:16AM +0100, Christian Ebert wrote:
> * Christian Ebert on Monday, November 29, 2010 at 11:11:11 +0100
> > term="/dev/$(ps -p$$ | awk '!/PID/ { print $2 }')"
>
> awk 'END { print $2 }'
>
> is better.
Since both select the desired line from the two lines presented by the
ps invocation, they do appear equivalent.
Despite being a long-term fan of awk, I would though offer an awk-less
means of providing $2, in case the extra command offends, in any form.
Since this:
term="/dev/$(ps -p $$ -o tty=)"
provides (only) $2 in the same format as the more vanilla ps invocation
above, it seems to do the job a little more directly.
Erik