Awk Notes
Print all fields in reverse order
This will take a "I-am-yoda" string and print out
yoda am i
Very useful for the next Star Wars sequel
awk -F '-' '{ for (i = NF; i > 0; --i) print $i }'
Print the last field instead of the first field
If you just want the last word, do this
echo $LOCAL | awk -F '-' '{ i = NF; print $i }'
BASH variable inside AWK command
It's rather difficult to find this on the internet. Hope it's useful.
awk -F '-' '{ i = NF; print $'${BASHVARIABLE}'}'