I am trying to understand what is the difference between two command (I was expecting same result from the two):
Case-I
echo 'one,two,three,four,five' |awk -v FS=, '{NF=3}1'
one two three
Case-II
echo 'one,two,three,four,five' |awk -v FS=, -v NF=3 '{$1=$1}1'
one two three four five
Here is my current understanding:
$1=$1 is used to force awk to reconstruct and use the variables defined. I am assigning FS like -v FS="," which is in effect unlike -v NF=3 .
Question: Why NF=3 is not taking effect where as FS=, does.