分类: Python/Ruby
2010-03-16 13:46:16
mishuang2010-04-23 14:48:09
最简单的表达式是man sed | col -b | cat -s # Delete all CONSECUTIVE blank lines from file except the first. # This method also deletes all blank lines from top and end of file. # (emulates "cat -s") sed '/./,/^$/!d' file # this allows 0 blanks at top, 1 at EOF sed '/^$/N;/\n$/D' file # this allows 1 blank at top, 0 at EOF http://sed.sourceforge.net/grabbag/tutorials/sedfaq.txt
chinaunix网友2010-03-22 13:15:39
杀鸡焉用牛刀? man page | col -b | sed '/^$/{N;/^\n$/D}' 再说就算要搬出 python,这个脚本也该只处理字符流啊,把执行 man,col 加里面干什么。Unix 哲学:每样东西做好它自己该作的就行了