Hi All,
my requirement is as below.
I need to replace a value in a particular column with a substitution variable(date value) and modified value of the current column value in the same position.
for ex.
i have a record like
02;aaaa;bbbbb;cccccc;dddddd;123456789;hhhhh;12hs;asdf ;
i need to insert date value(whiic is obtained from another record and stored in a variable $dt=20110702) at 6th column(123456) and also modify the current value as 123XXX789.
o/p should be like
02;aaaa;bbbbb;cccccc;dddddd;20110702;123XXX789;hhhhh;12hs;asdf
i need to modify my below code with AWK so that i can substitute the date value (which is stored in a variable $dt) in the 6th column
cat test1 | grep "02" > out
nawk '
BEGIN {
FS=OFS=";"
}
{$6=substr($6,1,3) "XXX" substr($6,7)}
1' out >> ofile
rm out
The file is a huge file and i do not want to open the file and change each line while i need to do some tweeking in the existing code to incorporate this change.Any help is greatly appreciated.