I have following strings in a file
DUPTASMTRMMBAL,20070416200704160117232101172321,,,,,,,@@@Y
DUPTASMTRMMCON,20070416200704160127189901271899,,,,,,,@@@Y
DUPTASMTRMMHG,,20070416200704160112051001120510,,,,,,,@@@Y
What i need to do is replace the date 20070416 with anoth date which is stored in variable enddate (enddate is result of certain calculations).
What i am tryning is this :-
for D in `cat file`;do
str1=`echo $D|cut -c1-15`
date1=`echo $D|cut -c16-23`
date2=`echo $D|cut -c24-31`
str2=`echo $D|cut -c32-`
enddate=$enddate
D=$str1$enddate$enddate$str2
done
This is not working.
Can someone please tell me an alternate method, using sed or awk. And also tell me why is this not working.