amitabhob wrote: ↑08 Jun 2018 14:03
Thanks to you all, the Developer for this impressive utility, and everyone of you, for your constant help & and valuable inputs.
I am very novice in the scripting area, and came across this forum while trying to find a solution for one requirement I have. Advance thanks to you all for your time and any help.
I have a big 300-400mb file, with contents something similar to, what is shown below.
The need is:
To replace, Only the 1st 3 characters i.e "ABC" with "00XXXX00-" (excluding quotes), in every line, but, only when, the first 15 chars begin with ABC and ends with DEF.
If this pattern exists somewhere else in the same line, then, no replacement to be done on the other patterns found.
For example: sampleTest.txt file has below content:
ABC123456789DEFAAAB1R$R36
ABC123456789DEF-0AAAB123AAAB12EF1TRYU
ABC1234567891234DEF--0AAAB123A124561AA2AEF34DEF111AATRE&*90
ABC671243598DEF34DEF111AAAB12EF111AAAB12#45*999SAHTYUP-0RRLKU
Expected output of the new file resultFile.txt is:
00XXXX00-123456789DEFAAAB1R$R36
ABC123456789DEF-0AAAB123AAAB12EF1TRYU
ABC1234567891234DEF--0AAAB123A124561AA2AEF34DEF111AATRE&*90
00XXXX00-671243598DEF34DEF111AAAB12EF111AAAB12#45*999SAHTYUP-0RRLKU
Note: on 1st line, there were 2 matching patterns, but replacement is done only on the 1st pattern on that line.
I was able to construct the command upto this:
type "sampleTest.txt"|jrepl "ABC.........DEF" "00XXXX00-" /B > "resultFile.txt"
With this, I am able to limit search to 1st 15 chars, but, this command will also replace all 15 chars, not just the 1st 3 Chars ABC, which is what I want to fix.
If you can please help, with the right command. Thanks again.