8

How do I get a field in bash's job list using awk?

view full story
linux-howto

http://unix.stackexchange.com – I wanted to write a function to retrieve a field from the list of background jobs in bash. For example to get a specific argument. Let's say I send vim to the background, so "jobs" displays this list: [1]+ Stopped vim ~/.bashrc My function looks like this: function jf { echo `jobs | awk 'NR==$1{print $$2}'`; } I then call it like this: jf 1 4 I would want it to return the 4th column of the 1st line, which would be "~/.bashrc", but it doesn't. What Am I doing wrong? (HowTos)