I need to replace anything that has 9� in column 21 and �1999' in column 42to be changed to have �1900'. It should keep the rest of the file that does not match this criteria intact.
Hello Sandeep,
I would suggest that you replace the complete string "000000000000199900000", if it is not a problem.
The command to use would be within vi and something like this
%s/old_word/new_word /g [this is within "vi". Command used to replace text (occurring any no. of times in the line) in the whole file (ignore /g if only first occurance in the line is to be replaced]
But be sure to make a copy of the original file before trying out this command.
I need to schedule this job and hence doing it from Vi editor will be manual. Hence i will not be using that, and the records that i have pasted here are just some sample records, so replacing the complete string "000000000000199900000" will be a problem.
The offsets in your latest example don't match what was posted before; do you have multiple adjacent spaces there? Please use code tags when posting material where spaces are significant.
The vi tip also works; you can use sed instead of vi, although the regular expressions would be getting rather clumsy.
If "9� is in column 21 and �00000000� in column 123 then i need to Change the �00000000� starting in column 123 to �19000101�.
This needs to works irrespective of if there are any spaces or not in the file.
The tried your code and it does not give me the required output.
This is just an example record and spaces vary in the file. But the "9� in column 21 and �00000000� in column 123 remain in the saem positions irrespective of wherever the space is.
If the offsets are different then change them. Based on what you posted before, the script looks for "9" in column 21 and "1999" in columns 42-45 (starting at 42, 4 positions). It's easy enough to change those.
Again, please use code tags when posting examples with significant spaces.