![]() |
replace specific character after specific line by awk
Hello,
I want to replace specific character in a file after every specific line. example as follows. O 000000000000000000 A 111111111111111111 C 222222222222222222 D 333333333333333333 O 000000000000000000 A 111111111111111111 C 222222222222222222 D 333333333333333333 I want to replace only O with T after specific interval starting from line 1 as can be seen from here. I would be highly grateful for the valuable suggestion or the way how to do this. Regards |
Looking at your example, we could guess that the code could match a string of zeros, or simply "O" at the beginning, or Line numbers 1,5,9,13...etc.
Here's three solutions---one for each option: Code:
sed '/0000000/s/O/T' filename > newfilename |
Code:
awk '$1=="O"{$1="T"}1' file |
| All times are GMT -5. The time now is 08:34 PM. |