I have looked around and there are several examples of how to use sed, but I don't think any of them help me very much with what I am trying to do.
I have a text file like this....
1! SRCNAM = 00001 !
1! X = 50.0000, 0.0000, 25.0000,0.2279E-07,0.0000E+00,0.3697E-07,0.0000E+00,0.0000E+00,0.3212E-08,0.4051E-10 ! !END!
10! SRCNAM = 00010 !
10! X = 50.0000, 0.0000, 25.0000,0.2296E-07,0.0000E+00,0.3757E-07,0.0000E+00,0.0000E+00,0.3254E-08,0.4123E-10 ! !END!
100! SRCNAM = 00100 !
100! X = 50.0000, 0.0000, 25.0000,0.1563E-06,0.0000E+00,0.2575E-06,0.0000E+00,0.0000E+00,0.2224E-07,0.2836E-09 ! !END!
1000! SRCNAM = 01000 !
1000! X = 50.0000, 0.0000, 25.0000,0.1563E-06,0.0000E+00,0.2575E-06,0.0000E+00,0.0000E+00,0.2223E-07,0.2836E-09 ! !END!
...and I would like to replace the entry "1" and "00001" with "1001" and "01001", respectively...and replace the entry "10" and "0010" with "1010" and "01010", respectively...and replace "100" and "00100" with "1100" and "01100", respectively...and replace "1000" and 01000" with "2000" and "02000", respectively.
The result I want would look like...
1001! SRCNAM = 01001 !
1001! X = 50.0000, 0.0000, 25.0000,0.2279E-07,0.0000E+00,0.3697E-07,0.0000E+00,0.0000E+00,0.3212E-08,0.4051E-10 ! !END!
1010! SRCNAM = 01010 !
1010! X = 50.0000, 0.0000, 25.0000,0.2296E-07,0.0000E+00,0.3757E-07,0.0000E+00,0.0000E+00,0.3254E-08,0.4123E-10 ! !END!
1100! SRCNAM = 01100 !
1100! X = 50.0000, 0.0000, 25.0000,0.1563E-06,0.0000E+00,0.2575E-06,0.0000E+00,0.0000E+00,0.2224E-07,0.2836E-09 ! !END!
2000! SRCNAM = 02000 !
2000! X = 50.0000, 0.0000, 25.0000,0.1563E-06,0.0000E+00,0.2575E-06,0.0000E+00,0.0000E+00,0.2223E-07,0.2836E-09 ! !END!
I plan to put the correct code to do this in a shell script and iterate through each line.
Is using sed the right way to go?
Any help is appreciated.