Created
November 17, 2017 14:18
-
-
Save cocodrino/d42a49523181e4b1d2c1655f8b6583ac to your computer and use it in GitHub Desktop.
remove or add coments to line with some pattern in some file through command line...ideal for dockerfiles
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
comment is | |
sed -i '/<pattern>/s/^/#/g' file | |
And to uncomment it: | |
sed -i '/<pattern>/s/^#//g' file | |
In your case: | |
sed -i '/2001/s/^/#/g' file (to comment out) | |
sed -i '/2001/s/^#//g' file (to uncomment) | |
comments line with text 2001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment