sed—stream editor (seeChapter 4)

sed [-n] [-V] [--quiet] [--silent] [--version] [--help] [-e script]
    [--expresion=script] [-f script-file] [--file=script-file]
    [script-if-no-other-script] [file…]

sed copies the named filename (standard input default) to the standard output, edited according to a script of command. Does not change the original file. (Read about sed in Chapter 4.) sed 's ability to filter text in a pipeline distinguishes it from other editors.

Example A.51.
1  sed 's/Elizabeth/Lizzy/g' file
2  sed '/Dork/d' file
3  sed -n '15,20p' file

Explanation

  1. Substitutes all occurrences of Elizabeth with Lizzy in file and displays on the terminal screen.

  2. Removes all lines containing Dork and prints the remaining lines on the screen.

  3. Prints ...

Get Linux Shells by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.