How do I display only the changed content when using a sed script?
-
Also see:
sed(1) - stream editor for filtering and transforming textDemo file:
$ cat breakfast coffee toast eggs butter jam honey hooney pie coffee 3 Cheese omelette
sed will normally display everything including the lines not affected by the sed script.
For example, changing toast to melon will give the following output.
$ sed -e 's/toast/melon/' breakfast coffee melon eggs butter jam honey hooney pie coffee 3 Cheese omelette
Only display the changed content.
$ sed -n -e 's/toast/melon/p' breakfast melon
The sed switch
-n
and sed commandp
-n, --quiet, --silent suppress automatic printing of pattern space p Print the current pattern space.
© Lightnetics 2024