I tried to print the argument before $NF. However $NF-- doesn’t do the trick. What is the solution to this? Problem is, I dono how many args I get, so I always need $NF and the arg before.
Kind Regards
Juergen
host -t ptr 1.1.1.1 | awk '/pointer/ {num=split($0,a, "."); print a[num-2] "." a[num-1] ;}'
foo.tld
You can use
$(NF - 1)to get the next to last field. So in your case: