awk '{print ; if (NF != 0) print ""}' infile > outfile
awk 'END {print NR}' infile
What does it mean by NF,NR?
Are those built-in variables?
awk '{print ; if (NF != 0) print ""}' infile > outfile
awk 'END {print NR}' infile
What does it mean by NF,NR?
Are those built-in variables?
Yes, they are built in variables.
NF is for the number of fields in the current record.
NR is for the number of records in the input file.
so in the above example from you have posted...
awk '{print ; if (NF != 0) print ""}' infile > outfile
it prints the current record from infile and checks for the field if it is not equals to 0, then it prints empty line.
awk 'END {print NR}' infile
After it process all the records(END will show what has been there after the file is processed), it prints the number of records from the infile.
And read..
man awk
NR is the number of the current record/line, not the number of records in the file.
Only in the END block (or on the last line fo the file) is it the number of lines in the file.