Skip to content

Instantly share code, notes, and snippets.

@abhinavkorpal
Created July 13, 2018 12:52
Show Gist options
  • Save abhinavkorpal/7d9f4d931444ef14a41e857fc826e89e to your computer and use it in GitHub Desktop.
Save abhinavkorpal/7d9f4d931444ef14a41e857fc826e89e to your computer and use it in GitHub Desktop.
Find and replace text within a file using commands
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