Skip to main content
2 of 3
Cleanup: Spelling, markup etc.
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Your file is ending in (Windows) CR LF instead of (Unix) LF.
The CR character moves the line to the start and then the value of the new calculated column is being printed over the first column.

Either use dos2unix filter the file with tr -d '\r' or simply use this:

awk 'NR>2 { gsub(/\r/,""); print $1,$2,$3,$4,$4-$3 } NR>12{exit}' file

remove the last NR>12{exit} to process the whole file.

user232326