Re: to replace a field of a line - help
From: Stefan Lagotzki (lago20_at_gmx.de)
Date: 03/04/04
- Next message: spanda: "Re: to replace a field of a line - help"
- Previous message: spanda: "to replace a field of a line - help"
- In reply to: spanda: "to replace a field of a line - help"
- Next in thread: spanda: "Re: to replace a field of a line - help"
- Reply: spanda: "Re: to replace a field of a line - help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 04 Mar 2004 14:06:18 +0100
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: spanda: "Re: to replace a field of a line - help"
- Previous message: spanda: "to replace a field of a line - help"
- In reply to: spanda: "to replace a field of a line - help"
- Next in thread: spanda: "Re: to replace a field of a line - help"
- Reply: spanda: "Re: to replace a field of a line - help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]