@~$ echo "abc:cde:efg" | awk 'BEGIN {FS=":"} {print $NF}' efg
The variable NF holds the number or records in the string, which is 3 in this case. So when you’re do a print $NF
, you are actually executing print $3
, and thus printing the last record/substring.