在AIX下使用sed c \ command

时间:2015-03-18 08:36:56

标签: sed aix

根据AIX手册页

http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.cmds5/sed.htm

他们在这里给出了c \命令的定义

(2)c\    
Text    
  

删除模式空间。使用0或1地址或在2地址范围的末尾,将Text变量放在输出中,然后开始下一个循环。

根据上面的解释,我对0或1地址的想法感到困惑。任何人都可以举例说明 c \ 命令的用法吗?

由于

1 个答案:

答案 0 :(得分:1)

c命令会将行更改为当前位置(通常是当前行,但可能使用缓冲区容量进行修改,例如使用n加载多行)

0,1或2地址范围意味着您可以在指令之前使用寻址范围(行号,模式匹配),如:

# no address, so current line
c \
Add this line

# 1 adress, so line number corrsponding or pattern line matchin
2 c\
at line 2
/This/ c\
at each line that contain "This"

# 2 address
1,3 c\
for line 1 to 3 only
/Trig/,$ c\
From first line that contain "Trig" until the end