Reputation: 478
I have the next command :
awk -v M="$variable" -v B=$"version"-v R="Pass ok" -v K="1" 'BEGIN {FS=","; OFS=","} $1==M {$14=R} {$3=B} {$23=K} {print}' file1.csv > file2.csv
and i dont know why i get an output different than i wish, the parameter (R="Pass ok")
the prints in several's lines of the file like the parameter (K="1")
, please help me with this.
Notes :
I have this command in a script that i run of this way :
./myscript.sh
variable
Upvotes: 0
Views: 59
Reputation: 5861
i dont know why i get an output different than i wish
Because you wrote everything on a single line and you lost track of what pattern applies to what action. Try this instead:
awk -v M="$variable" -v B="$version"-v R="Pass ok" -v K=1 '
BEGIN { FS=","; OFS="," }
$1 == M { $14 = R; $3 = B; $23 = K; print }
$1 != M
' file1.csv > file2.csv
Upvotes: 1