sed行对象【列表】和单个字符对象【替换】

               Bash sed【行列表】和【字符替换】     

一、List

List the specific item lines.

-n forbids default print.

[braveyly@m-net ~]$ cat sedly.txt

word

abc

aTC

[braveyly@m-net ~]$sed -n l ./sedly.txt

word$

abc$

aTC$

[braveyly@m-net ~]$sed -n '/abc/l' ./sedly.txt

abc$

[braveyly@m-net ~]$ sed l ./sedly.txt

word$

word

abc$

abc

aTC$

aTC

 

二、Transfer

For example, transfter lower case letters to capital letters.

         linenumy/abc/ABC/

       In the linenum line, replace abc with ABC.


         /keyword/y/abc/ABC/

         In the lines positioned by keyword, replace abc with ABC.

[braveyly@m-net ~]$ cat sedly.txt

word

abc

aTC

[braveyly@m-net ~]$ sed -e 'y/abc/ABC/' ./sedly.txt

word

ABC

ATC

[braveyly@m-net ~]$sed -e '2y/abc/ABC/' ./sedly.txt

word

ABC

aTC

[braveyly@m-net ~]$sed -e '/T/y/abc/ABC/' ./sedly.txt

word

abc

ATC

 

 

你可能感兴趣的:(bash)