sed
sed: stream editor
use it to filter and modify text, e.g. in-place within text-files.
example file, tonics.txt:
Delicious tonic combinations:
1. Ginger, Carrot, Apple
2. Orange, Ginger, Lime
3. Ginger, Pineapple, Blood orange
4. Whey protein, Banana, Ginger
5. Oat milk, Ginger
example: replace Ginger with Lemon from tonics.txt, without overwriting the file
sed 's/Ginger/Lemon/' tonics.txt
example: replace file inplace:
sed -i 's/Ginger/Lemon/' tonics.txt
delete word
sed 's/Ginger//' tonics.txt
delimiters
if one of the characters you want to replace is a forward slash, /,
use a different delimiter.
example:
find /etc -type f > paths.txt
cat paths.txt
deletion:
sed 's./etc..' paths.txt
replacement:
sed 's./etc.something-else.' paths.txt
example:
echo "Code Vault" | sed 's/Vault/Hive/'