Skip to main content
added 4 characters in body
Source Link
user232326
user232326

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, or 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.

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.

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, or 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.

Cleanup: Spelling, markup etc.
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Your file is ending in (Windows) CR LF instead of (linuxUnix) 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 dos2linuxdos2unix filter the file with tr -d '\r' or simply use this:

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

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

Your file is ending in (Windows) CR LF instead of (linux) 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 dos2linux 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 to process the whole file.

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.

Source Link
user232326
user232326

Your file is ending in (Windows) CR LF instead of (linux) 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 dos2linux 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 to process the whole file.