User Tools

Site Tools


sed:print:print

SED - Print - Print

Printing duplicated lines with /p flag

The /p print flag prints the replaced line twice on the terminal.

If a line does not have the search pattern and is not replaced, then the /p prints that line only once.

sed 's/unix/linux/p' filename

Printing only replaced lines

Use the -n option along with the /p print flag to display only the replaced lines.

Here the -n option suppresses the duplicate rows generated by the /p flag and prints the replaced lines only one time.

sed -n 's/unix/linux/p' filename
sed/print/print.txt · Last modified: 2020/08/17 23:23 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki