I try to modify one column of my file, then print the result.
awk -F"|" '{ if(NR!=1){$5 = $5+0.1} print $0}' myfile
It does what I want, but when printing, only the first line keeps its field separator.( the one, i don't modify).
So I could use print $1"|"$2"|"$3"|"$4"|"$5"|"...
but isn't there a solution using $0 ? (For example if I don't know the numbers of column)
I believe, I could solve my problem easily with sed
, but I try to learn awk
for now.
sed
is not the correct tool for this (it doesn't understand columns). You are right in usingawk
. – gardenhead Jan 01 '16 at 21:45sed
not understand columns, it also doesn't understand numbers at all. It is purely for text. It would be extraordinarily difficult and hacky to set up ased
command to "add 0.1 to a number". :) – Wildcard Jan 02 '16 at 05:24