Title: sed
Course: CIS 121: Linux/UNIX I: Fundamentals ~ For IGNITE Review > Section: Learning Modules

The sed command is very complex and powerful.  One of the many things that sed can do is display the contents of a file while searching for a pattern (limited regular expression), and replacing the found pattern with some new data.

One command syntax: sed 's/pattern/new_data/' filename:

- This will display the contents of the file while
  - searching for lines with 'pattern' and
  - replacing the pattern with 'new_data'.

By default sed acts on only the first occurrence of a matched pattern. The pattern is a limited regular expression.

- Example: sed 's/dog/cat/' file1
- This example displays all the lines of file1 with the first occurrence of 'dog' on any line changed to 'cat'.

NOTE:

- The file is not being changed.
- Sed is not effected by the LC_COLLATE setting.