Re: How to awk global replace second field with double quoted string.



On Jun 18, 5:54 pm, Tonagon <tony.robe...@xxxxxxxxxxxx> wrote:

Worked like a charm!
gawk '{gsub ($2, "\"5AB0\"")}1' $FILE1 > $FILE2
Gets me what I need in FILE2 with the second field set as "5AB0"
I was missing that }1 piece, which quite frankly I don't understand at
all.
What is that {1 doing?


It is not {1, but simply 1, which, as an always true condition
triggers, the default action, i.e. prints the record.

A slightly different way of expressing the same logic would be:

gawk 'gsub($2, "\"5AB0\"")+1' $FILE1 > $FILE2

Hermann

.



Relevant Pages