+ -
当前位置:首页 → 问答吧 → 请教个问题,请各位不吝赐教

请教个问题,请各位不吝赐教

时间:2011-04-19

来源:互联网

如下的脚本
代码:
#!/bin/sed -nf

     # Prime the pump on the first line
     x
     /^$/ s/^.*$/1/
   

     # Add the correct line number before the pattern
     G
     h

     # Format it and print it
     s/^/      /
     s/^ *\(......\)\n/\1  /p

     # Get the line number from hold space; add a zero
     # if we're going to add a digit on the next line
     g
     s/\n.*$//
     /^9*$/ s/^/0/

     # separate changing/unchanged digits with an x
     s/.9*$/x&/

     # keep changing digits in hold space
     h
     s/^.*x//
     y/0123456789/1234567890/
     x

     # keep unchanged digits in pattern space
     s/x.*$//
     # compose the new number, remove the newline implicitly added by G
     G
     s/\n//
     h


初学sed,这一行没看懂
引用:
/^$/ s/^.*$/1/
,哪位大侠能指点下~~多谢

作者: cnLiuyix   发布时间: 2011-04-19