perl -i -pe '
BEGIN{
%h=qw(
JAN 01
FEB 02
MAR 03
APR 04
MAY 05
JUN 06
JUL 07
AUG 08
SEP 09
OCT 10
NOV 11
DEC 12
);} foreach $k (keys %h){ s/(\d+)$k(\d+)/$h{$k}\\$1\\$2/ };' infile
Thanks for you help!!!
I tried with your code,
however it does not changes all the requred substrings in one go i had to run the same scrip twice to get desired results.
My text file was 1,000,000 + records and this scrip is not capable of produting anothe file, it acts on same file. I am new to this coading please bear me,.
awk -F\| 'BEGIN{split("JAN FEB MAR APR MAI JUN JUL AUG SEP OCT NOV DEC",A," "); while (++i in A)M[A]=i; D[3]; D[6]}
{for(i in D)$i=sprintf("%02d\\%s\\%s",M[substr($i,3,3)],substr($i,1,2),substr($i,6))}1' OFS=\|
## justdoit ##
ls -1 desiredfiles |
while read -r infile ; do
# backup
cp $infile $infile_bck
# process
x="JAN=01 FEB=02 MAR=03 APR=04 MAY=05 JUN=06 JUL=07 AUG=08 SEP=09 OCT=10 NOV=11 DEC=12"
for i in $(echo "$x" | sed 's/=[0-9]*//g') ; do
y=$(sed "s/.*\($i\).*/\1/" $infile); y1=$(echo "$x"| sed "s/.*$i=\([0-9]*\).*/\1/")
sed -i "s/\(.*\)|\(.*\)$y\(.*\)|\(.*\)/\1|$y1\\\\\2\\\\\3\4|/g" $infile 2>/dev/null
done ; more $infile
done