I have a config file that I want to basically edit the uncommented lines, but not the commented lines. I’m using sed.
For example, I have a file called file.txt:
test # test # test test
I want to replace “test” with “TEST” but do NOT touch the commented lines. Final output should show:
TEST # test # test TEST
Output
*Note: If your only requirement for a comment is that the very first non-whitespace character is a
#, then you can use:Output