saj
January 7, 2013, 3:09am
1
Hi
cat test.txt
H|123|341|567|asfg
D|dfg|trtyy|errt
D|ert|frty|wer
Here I need to replace the third column value with 100 of the first record only and while printing I need to print the full file content also..I am expecting a result like this
H|123|100|567|asfg
D|dfg|trtyy|errt
D|ert|frty|wer
Can some one please help on this
Try:
awk -F"|" -vOFS="|" 'NR==1{$3=100}1' file
saj
January 7, 2013, 3:29am
3
Thanks for the quick post ..But its giving me syntax error
awk: syntax error near line 1
awk: bailing out near line
---------- Post updated at 03:29 AM ---------- Previous update was at 03:24 AM ----------
I tried something like this
awk -F"|" -vOFS="|" 'NR==1{$3=100} {print}' file
Its working , but the problem is that its replacing the delimter pipe with space
try this..
$ nawk -F\| 'NR==1{$3=100;OFS="|";}1' input.txt
H|123|100|567|asfg
D|dfg|trtyy|errt
D|ert|frty|wer