Re: to replace a field of a line - help
From: spanda (spanda_at_cisco.com)
Date: 03/04/04
- Next message: Francesco: "Suppressing [CR] when using diff"
- Previous message: Stefan Lagotzki: "Re: to replace a field of a line - help"
- In reply to: Stefan Lagotzki: "Re: to replace a field of a line - help"
- Next in thread: Stefan Lagotzki: "Re: to replace a field of a line - help"
- Reply: Stefan Lagotzki: "Re: to replace a field of a line - help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 4 Mar 2004 18:59:27 +0530
Hi Stefan,
Thanks for ur reply.
Here the point is I don't know the content of the 4th field ie. good.
And I want to replace it directly with a new word.
How can I do that ?
Regards
Subrat
"Stefan Lagotzki" <lago20@gmx.de> wrote in message
news:c279nb$tf2$06$1@news.t-online.com...
> spanda <spanda@cisco.com>:
> > I want to replace a field of a line without knowing the content of the
> > field.
> > i.e if a line is "he is a good guy" and I want to replace the 4th field
> > (good) and the new line
> > should be "he is a nice guy".
>
> awk '{gsub(/good/,"nice",$4);print}' input.txt > output.txt
>
> Test:
>
> echo "he is a good guy" | awk '{gsub(/good/,"nice",$4);print}'
> he is a nice guy
>
> HTH,
> Stefan
>
> .
>
- Next message: Francesco: "Suppressing [CR] when using diff"
- Previous message: Stefan Lagotzki: "Re: to replace a field of a line - help"
- In reply to: Stefan Lagotzki: "Re: to replace a field of a line - help"
- Next in thread: Stefan Lagotzki: "Re: to replace a field of a line - help"
- Reply: Stefan Lagotzki: "Re: to replace a field of a line - help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|