Using `sed` to find and replace in file
sed = Stream EDitor
PreviousMacOS's Touch ID on TerminalNextMerging contents of multiple .csv files into single .csv file
Last updated
Was this helpful?
sed = Stream EDitor
Last updated
Was this helpful?
Was this helpful?
sed 's/word1/word2/g' input.file
Find and replace text and save to new file
sed 's/word1/word2/g' input.file > output.file
Note:
s/
means substitute
/g
means global replace
/
to something else:sed 's~word1~word2~g' input.file > output.file
sed -i -e '/FOO/s/love/sick/' input.txt
In this example only find the word love
and replace it with the sick
if line content a specific string such as FOO
find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \;
-i
to save the temporary file