As for this Command:
awk '{for(x=1;x<=NF;x++)if($x~/0.00000/){sub(/0.00000/,++i)}}1'
I know this command will look for "0.00000" in a file and replace it with an incremental number starting from 1. I understood almost everything except for 'x<=NF' and the number 1 at the end "{sub(/0.00000/,++i)}}1'. Can you enlighten me on these two points, please?
Also, If I want to do the same thing but replacing the match with an incremental number starting from 0, would it be correct to do:
awk '{for(x=0;x<=NF;x++)if($x~/0.00000/){sub(/0.00000/,++i)}}1' file
$0
) in addition to each individual field ($1
to$NF
) – steeldriver Oct 11 '18 at 19:39for(x=0
and so forth. That is where the start of the loop is defined. – DopeGhoti Oct 11 '18 at 19:491
answer here: https://unix.stackexchange.com/questions/63891/what-is-the-meaning-of-1-at-the-end-of-awk-script – Roland Apr 06 '20 at 09:11