Last active
February 15, 2019 23:55
-
-
Save mikybars/d6cebf40a840e58ad866e6de9ecef9f9 to your computer and use it in GitHub Desktop.
We have two options here: * `sed` is a powerful **stream** editor although it also features a handy in-place/`-i` flag that may modify the source file. Unfortunately this is a non-standard FreeBSD extension and therefore results in unportable code.
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
# Replace the shell executing the script | |
$ ex - '+g/^#!/s,bash,zsh,' -cwq install.sh | |
# Comment all non-commentary lines | |
$ ex - '+g/^[[:space:]]*[^#]/s/^/#/' -cwq test.sh |
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
# Replace the shell executing the script | |
$ sed -i -e 's,bash,zsh,' install.sh | |
# sed can also create a backup file if an extension is provided to the -i flag | |
$ sed -i.bak -e 's/private/public/' MyClass.java | |
$ ls MyClass.* | |
Myclass.java MyClass.java.bak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment