sed tools

Sed command syntax as follows:

sed [options] command file(s)              

or:

sed [options] -f script file(s)                 

The above command format, showing the use of two methods of Sed. The first method call, the edit command is placed directly behind this option is the most common one. When performing some of the more complex editing operations using the editing commands may be very long, then for ease of reading, editing instruction is typically placed in a script file, edit the file to invoke Sed by the second method.

Note: Sed and grep is not the same, regardless of whether or not find the specified pattern, its exit status is 0, only when there is a syntax error command, Sed-like exit

   Sed Features

Sed as the editor is a very powerful tool that has the following characteristics:

(1) a non-interactive, filtered, and modify the text based on pattern matching.

(2) progressive processing, large files using Sed will be extraordinarily advantageous.

(3) enables the output of the text, delete, replace, copy, cut, import, export, and various editing

(4) scripted using vim Sed convenient than the shell script programming.

 Sed usage

Sed using rules and options in the table below.

                                                                                              Sed command common options

Command Options

description

-n

Use quiet (silent) mode. In general usage Sed, all data from stdin generally will be listed to the screen, but if coupled with -n parameter, only through Sed special treatment that line (or command) will be listed.

-e

It allows you to add a new editing commands behind this option. When multiple editing instructions should be added one by one using this option, if you edit only one instruction, you can not use this option.

-f

Sed write directly to the action in a file, -f finame Sed action can be performed within the filename.

-i

Read directly modify the contents of the file, rather than the output from the screen.

-r

It supports extended regular expressions.

-h

Sed output of help information.

Sed command syntax as follows:

sed [options] command file(s)              

or:

sed [options] -f script file(s)                 

The above command format, showing the use of two methods of Sed. The first method call, the edit command is placed directly behind this option is the most common one. When performing some of the more complex editing operations using the editing commands may be very long, then for ease of reading, editing instruction is typically placed in a script file, edit the file to invoke Sed by the second method.

Note: Sed and grep is not the same, regardless of whether or not find the specified pattern, its exit status is 0, only when there is a syntax error command, Sed is a non-zero exit status.

8.3.2            Sed Features

Sed as the editor is a very powerful tool that has the following characteristics:

(1) a non-interactive, filtered, and modify the text based on pattern matching.

(2) progressive processing, large files using Sed will be extraordinarily advantageous.

(3) enables the output of the text, delete, replace, copy, cut, import, export, and various editing

(4) scripted using vim Sed convenient than the shell script programming.

8.1  Sed usage

Sed using rules and options are shown in Table 8.1.

                                                                                           Table 8.1 Sed command common options

Command Options

description

-n

Use quiet (silent) mode. In general usage Sed, all data from stdin generally will be listed to the screen, but if coupled with -n parameter, only through Sed special treatment that line (or command) will be listed.

-e

允许在该选项后面加一条新的编辑指令。当有多条编辑指令时,应该使用该选项逐一添加,如果编辑指令只有一条,可以不使用该选项。

-f

直接将Sed的动作写在一个档案内,-f finame 则可以执行filename内的Sed动作。

-i

直接修改读取的档案内容,而不是由屏幕输出。

-r

支持扩展正则表达式。

-h

输出Sed的帮助信息。

Guess you like

Origin www.cnblogs.com/momenglin/p/11375219.html
sed