Skip to main content
1 of 3
user avatar
user avatar

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.

user232326