I have a file "dummy" in which: If 15 character of the file matches with "R" and 28 character of the file matches with "D" then 53-56 characters should be replaced with 0.
I have tried using the below script, but it's not working.
for i in `cat dummy`
do
if [[ `echo $i | cut -c15` = "R" ]] && [[ `echo $i | cut -c28` = "D" ]]
then
sed -e 's/./0/53' -e 's/./0/54' -e 's/./0/55' -e 's/./0/56'
fi
done
Input File: dummy
05196220141228R201412241308D201412200055SA1155WE130800031300SL07Y051
05196220141228R201412241308A201412220350SA0731SU1950LAX C00020202020
05196220141228R201412241308D201412200055SA1155WE130823455300SL07Y051
05196220141228N201412241308A201412240007TU0548WE1107MEL C00000000015
07054820141228N201412220850D201412180300TH1400MO085000040300UL180001
Output should be:
05196220141228R201412241308D201412200055SA1155WE130800001300SL07Y051
05196220141228R201412241308A201412220350SA0731SU1950LAX C00020202020
05196220141228R201412241308D201412200055SA1155WE130800005300SL07Y051
05196220141228N201412241308A201412240007TU0548WE1107MEL C00000000015
07054820141228N201412220850D201412180300TH1400MO085000040300UL180001