Created
September 1, 2015 06:10
-
-
Save haisum/4fcd9146b6c972d0d3ca to your computer and use it in GitHub Desktop.
comment and uncomment lines in bash script via sed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed -i '/<pattern>/s/^/#/g' file #comment | |
sed -i '/<pattern>/s/^#//g' file #uncomment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will add multiple # if executed multiple times..If you want to add # only once even after multiple times command execution then you can use this:
sed -e '/<pattern>/ s/^#*/#/g' -i file