Friday, 23 August 2013

how to do simple concat in awk in mac

how to do simple concat in awk in mac

So I have a file list.txt similar to this one:
186
423
423
234
634
437
And I want an output similar to this:
SET 186 0
SET 423 0
SET 423 0
SET 234 0
SET 634 0
SET 437 0
I tried with this:
sed 's/^ *//g' list.txt | | awk '{a="SET ";b=" 0";print a,$0,b}'
But it prints
0 80349851
0 82988801
0 83003371
0 79515621
0 83228451
Given that
sed 's/^ *//g' list.txt | | awk '{a="SET ";b=" 0";print a,$0}'
Works perfect. So I don't know what I'm doing wrong.
Do you know how to solve this and why print a,$0,b doesn't work?

No comments:

Post a Comment