Using SED tool for replacing text in files

Posted on 14-04-2017 by Nadir Latif


Source: https://www.gnu.org/software/sed/manual/sed.txt

It describes how to use the SED command line tool for removing text inside a file. Following script can be used for updating all occurrences of a text inside files:

find folder_name -type f -print0 | xargs -0 sed -i 's/current_text/new_text/g'
Reference:
  1. www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/
  2. http://stackoverflow.com/questions/6945621/using-sed-to-remove-a-block-of-text/36493035#36493035 (added a new answer)
  3. http://stackoverflow.com/questions/1583219/awk-sed-how-to-do-a-recursive-find-replace-of-a-string