All Articles

Enough sed - substitute

Let’s take a look at our test.txt file with the following content:

sad
happy
awake
coffee
work
school

If we want to substitute the word coffee with water, we would do the following:

$ sed 's/coffee/water/' test.txt
sad
happy
awake
water
work
school
$

Note that this does not change the original test.txt file.

Published May 20, 2024

I love coffee, coding and writing.