Replacing lines in files that contain special characters
I want to un-comment (remove the fist #) from a bunch of lines in a file where the lines contain various special characters (as far as regular expressions are concerned) and I can't figure out how to do it in a bash script.
Example of lines: Code:
# text[NORMAL] = @text_color It occurs to me I could write the modified lines to a another file, then replace the original file with the new one, but that seems very inefficient. Code:
#!/bin/bash |
man you are making life difficult
??? what chars? e.g. for @ or # perl -i.bak -pe 's/^#// if m/[@#]/' file_to_edit |
Code:
awk '/^#.*[@#]/{sub(/^#/,"")}1' file |
Spaces are being lost in the lines stored in variables when they are echoed into sed.
The variables should be in quotes or echo will squeeze runs of spaces down to a single space. Code:
line='# text[NORMAL] = @text_color' |
All times are GMT -5. The time now is 06:57 AM. |