Prayer

在一般中寻求卓越
posts - 1256, comments - 190, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

sed label

Posted on 2010-01-19 17:00 Prayer 阅读(373) 评论(0)  编辑 收藏 引用 所属分类: Shell
http://www.gnu.org/software/sed/manual/html_node/Programming-Commands.html

 Commands for sed gurus

In most cases, use of these commands indicates that you are probably better off programming in something like awk or Perl. But occasionally one is committed to sticking with sed, and these commands can enable one to write quite convoluted scripts.

: label
[No addresses allowed.]

Specify the location of label for branch commands. In all other respects, a no-op.

b label
Unconditionally branch to label. The label may be omitted, in which case the next cycle is started.
t label
Branch to label only if there has been a successful substitution since the last input line was read or conditional branch was taken. The label may be omitted, in which case the next cycle is started.
主要 和  t   ;    b  命令联合使用
冒号开头:后面随便借个字母   设置个label  例如:f
b a  ; 表示无条件到:a 这里继续执行 例子 ':a;$!N;$!ba;$s/\n/g'  所有内容 一行输出 循环作用
t a  ;   表示前面的s/   /   成功比配到 了 变 跳转到:a继续执行 例子':a;N;s/aa\nbb/woyn/;ta;P;D'

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理