Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4733975
  • 博文数量: 930
  • 博客积分: 12070
  • 博客等级: 上将
  • 技术积分: 11448
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-15 16:57
文章分类

全部博文(930)

文章存档

2011年(60)

2010年(220)

2009年(371)

2008年(279)

分类:

2008-11-11 13:29:33

混shell论坛发现awk基本掌握了,数组,内置函数都能熟练使用了,sed还有点欠缺,温故了下
sed & awk的advanced sed command.做了些小笔记
  sed '//{N;c\.LP}' sed.data
 sed: -e expression #1, char 0: unmatched `{'

 这是为什么呢?原来c把起后面的都当要替换的行了,于是{括号不匹配了.
  应该放在脚本里
  /<para>/{
     N
     c\
  .LP
  }
  sed -f sed sed.data就可以了
  c,i,w,a这些用的少,都快忘了.


  删除偶数个空行,奇数个空行的话,删除为一个空行
  /^$/{
    N
    /^\n$/d
  }

  删除多个空行为一个空行
  /^$/{
    N
    /^\n$/D
  }

3.
  The pattern space is a buffer that contains the current input line
                                                                   
  There is also a set-aside buffer called the hold space. The contents
of the pattern space can be copied to the hold space and the contents
of the hold space can be copied to the pattern space.

  Command Abbreviation Function
  
  Hold h or H Copy or append contents of pattern space to hold space.
  Get g or G Copy or append contents of hold space to pattern space.
  Exchange x Swap contents of hold space and pattern space.

4.删除注释
  awk -F"#" '$1{print $1}' test
  sed 's/#.*//g;/^$/d' test

阅读(1606) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~