awk '{ print NR "\t" $0 }'
# Example
awk '{ print NR "\t" $0 }' FILE_IN > FILE_OT
awk '{ total = total + NF }; END { print total+0 }'
# Ex
awk '{ total = total + NF }; END { print total+0 }' FILE_IN > FILE_OT
awk 'END { print NR }'
#Ex:
awk 'END { print NR }' FILE_IN > FILE_OT
1. numbereachline.bash : Number lines in each file separately
2. numberallline.bash : Number lines on all files together
3. numberspacecolon.bash : Number lines with space and colon
4. numbernonblank.bahs : Number non blank lines
5. countlines.bash : Count lines in file (wc -l)
6. sumofallfields.bash : Print the sum of all fields in every line
7. sumofallfieldsallines.bash : Print the sum of all fields in all lines
8. replaceabs.bash : Replace every field with its abs value
9. countwordstotal.bash : Count total number of words per file
awk '{ for (i = 1; i <= NF; i++) s = s+$i }; END { print s+0 }'
#Ex:
awk '{ for (i = 1; i <= NF; i++) s = s+$i }; END { print s+0 }' FILE_IN > FILE_OT
awk '{ s = 0; for (i = 1; i <= NF; i++) s = s+$i; print s }'
# Ex
awk '{ s = 0; for (i = 1; i <= NF; i++) s = s+$i; print s }' FILE_IN FILE_OT
awk '{ for (i = 1; i <= NF; i++) if ($i < 0) $i = -$i; print }'
# Ex
awk '{ for (i = 1; i <= NF; i++) if ($i < 0) $i = -$i; print }' FILE_IN > FILE_OT