in a text file I want to search for a line containing specific text and at the next line I want to substitute beginning of a line with #(comment it out) inplace:
Example - before:
#test search 123
text to be commented out
#test 123
Example - wanted:
#test search 123
#text to be commented out
#test 123
I can do it via sed:
sed -i '/^#test search 123/!b; n; s/^/#/' test_file
but i was wondering if I'm able to do it natively in python.