I wrote a function inside a bash script with some help:
function test() {
temp=$(cat /etc/passwd | grep $(whoami) | awk -F : "{print $`echo $1`}")
echo "$temp"
}
I give it a number X and it should print the Xth column from the users entry in the passwd file.
echo $(test "3")
...will give me the entry of the third column. I have trouble understanding how the awk part works. How does the echo part in
"{print $`echo $1`}"
access the functions $1
and not the $1
from the pipe?