混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