I have a text file and I would like to search and replace it using shell scripts. How do I go about doing that?
I would like to replace HIGH AA to HIGH BB if MODE BAD. If MODE GOOD, then do nothing.
Example: mytext.txt
##############
MODE BAD1
HIGH AA ;
END NAME1
MODE BAD2
HIGH AA ;
END NAME2
MODE GOOD1
HIGH AA
END
##################
Example: mytext_new.txt
##################
MODE BAD1
HIGH BB ;
END NAME1
MODE BAD2
HIGH BB ;
END NAME2
MODE GOOD1
HIGH AA
END
#####################
Chang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1