O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. Using sed

Sed is a non-interactive text stream editor for editing a copy of text from a file or from standard input. Standard input can be text entered from the keyboard, a file redirection, a string or a variable, or by a pipe. So what would you use sed for? After all, vi is also a text editor. Well, sed allows you to edit small or large files on the fly; you can supply a series of sed commands to edit or delete and off it goes and does the job. Sed does all the changes in one pass, thus making it efficient and, most importantly to the user, fast.

In this chapter we will cover:

  • extracting fields;

  • matching with regular expressions;

  • comparing fields;

  • adding, appending and substitution; and

  • basic sed one-liners and scripts.

You supply ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required