Created
July 13, 2018 12:52
-
-
Save abhinavkorpal/7d9f4d931444ef14a41e857fc826e89e to your computer and use it in GitHub Desktop.
Find and replace text within a file using commands
This file contains hidden or 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 's/original/new/g' file.txt | |
Explanation: | |
sed = Stream EDitor | |
-i = in-place (i.e. save back to the original file) | |
The command string: | |
s = the substitute command | |
original = a regular expression describing the word to replace (or just the word itself) | |
new = the text to replace it with | |
g = global (i.e. replace all and not just the first occurrence) | |
file.txt = the file name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment