Resources · April 25, 2021 0

Find and replace text within a file using sed command

Find and replace text within a file using sed command on Linux:

# sed -i ‘s/old-text/new-text/g’ input.txt

Replace all occurances of ‘old-text’ with ‘new-text’ in the file input.txt, without creating a backup of the file on FreeBSD:

# sed -i ” -e ‘s/old-text/new-text/g’ input.txt