Полезная информация

sed & awk

sed & awkSearch this book
Previous: 13.10 m1 - Simple Macro ProcessorAppendix ANext: A.2 Syntax of sed Commands

A. Quick Reference for sed

Command-Line Syntax
Syntax of sed Commands
Command Summary for sed

A.1 Command-Line Syntax

The syntax for invoking sed has two forms:

sed [-n][-e] `command' file(s)
sed [-n] -f scriptfile file(s)

The first form allows you to specify an editing command on the command line, surrounded by single quotes. The second form allows you to specify a scriptfile, a file containing sed commands. Both forms may be used together, and they may be used multiple times. The resulting editing script is the concatenation of the commands and script files.

The following options are recognized:


Only print lines specified with the p command or the p flag of the s command.

-e cmd

Next argument is an editing command. Useful if multiple scripts are specified.

-f file

Next argument is a file containing editing commands.

If the first line of the script is "#n", sed behaves as if -n had been specified.

Frequently used sed scripts are usually invoked from a shell script. Since this is the same for sed or awk, see the section "Shell Wrapper for Invoking awk" in Appendix B, Quick Reference for awk.

Previous: 13.10 m1 - Simple Macro Processorsed & awkNext: A.2 Syntax of sed Commands
13.10 m1 - Simple Macro ProcessorBook IndexA.2 Syntax of sed Commands

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System