sed
Hi,
I have a text file as follows: Line1....... 1111ABC Line2....... 1134ABC Line3....... 1149ABC Line4....... 2140ABC I just want to replace all ABC to DEF and increment all number by 1 if the number start with 11 The output file should be: Line1....... 1112ABC Line2....... 1135ABC Line3....... 1150ABC Line4....... 2140ABC Can anyone tell me how to write a sed script to handle this case? Thank |
I'm no sed guru but i see a problem with the increment operation. Afik sed doesn't do maths. And it's not just a matter of replacing 1 with2, 2 with 3,... , there is the question of the carry on.
My way out of that would be to use a scripting langage with regular expressions. Here is my suggestion in Python: Code:
# type the following to run the pgm: |
OK, let's have some fun with shell scripting, another programming language that has regular expressions and that can do maths ;)
Code:
#!/bin/bash |
All times are GMT -5. The time now is 08:31 PM. |