My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found..The issue is the last two digits in "0108" tells the year..The file may contain "0109","0110" and so on...i need to replace the correct year depending on the last two digits of the string..How do i go about??please help me....
This is not working whiteboard.....it jus replaces the string and displays since print statement is given in AWK.... i need to replace in the actual file itself.....
The file contains many numerical values ...so there may be many places where 0108 occurs...i need to find the string 0108/ and search it with 2008...how to do it white???
white its working fine when i hardcode the values 0108/ with 2008..but i do not know which year will come in the wrong format...it may be 0109 or 0199 or anything...i need to search like for the 0***/ pattern i.e the year get the last two char and depending on it i need to replace it with the corresponding year...
for eg i get 0109/ i need to replace with 2009...
in the next line i may get 0110/ i need to replace with 2010...
ok i can do like this for 0108/
but if i need to replace for 0109/ , 0110/.....0199/ ????
i need to put this in a loop and check the last two digits of the 0***/ and replace it with the corresponding year...
My question is can i use"$" variables inside awk'.....' ???? like awk '{gsub (/0$i/,"20$j")....' ????