Quick search and replace inside file

sed -i 's/original/new/g' file.txt

Where

  • sed means Stream EDitor
  • -i – in-place (for example save back to the original file)
  • 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 (replace all and not just the first occurrence)
  • myfile.txt – the file name

 

Leave a Reply

Your email address will not be published. Required fields are marked *