Re: How to awk global replace second field with double quoted string.
- From: Hermann Peifer <peifer@xxxxxxx>
- Date: Wed, 18 Jun 2008 09:41:38 -0700 (PDT)
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
.
- Follow-Ups:
- Re: How to awk global replace second field with double quoted string.
- From: Hermann Peifer
- Re: How to awk global replace second field with double quoted string.
- From: Tonagon
- Re: How to awk global replace second field with double quoted string.
- References:
- Prev by Date: Re: How to awk global replace second field with double quoted string.
- Next by Date: multiple substitutions with sed
- Previous by thread: Re: How to awk global replace second field with double quoted string.
- Next by thread: Re: How to awk global replace second field with double quoted string.
- Index(es):
Relevant Pages
|