Re: to replace a field of a line - help
From: Stefan Lagotzki (lago20_at_gmx.de)
Date: 03/04/04
- Next message: Suhas: "HTML attachment using sendmail"
- Previous message: Francesco: "Suppressing [CR] when using diff"
- In reply to: spanda: "Re: 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"
- Reply: spanda: "Re: to replace a field of a line - help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 04 Mar 2004 15:01:18 +0100
Hi Subrat,
spanda <spanda@cisco.com>:
> 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.
echo "he is a good guy" | awk '{$4="nice";print}'
he is a nice guy
awk '{$4="nice";print}' input.txt > output.txt
With a modern Version of awk you may use:
awk -v replace_string="nice" '{$4=replace_string;print}' input > output
Stefan
.
- Next message: Suhas: "HTML attachment using sendmail"
- Previous message: Francesco: "Suppressing [CR] when using diff"
- In reply to: spanda: "Re: 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"
- Reply: spanda: "Re: to replace a field of a line - help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]