ChinaUnix.net
相关文章推荐:

linux sed 删除空行

sed "/^\s*$/d" file 请问"/^\s*$/d",这是什么意思,没看懂。谁可以解释一下?谢谢。

by hiller1 - Shell - 2011-05-09 18:18:02 阅读(20217) 回复(18)

相关讨论

test文件如下 #!/usr/bin/python from gi.repository import Gtk class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Hello World") self.button = Gtk.Button(label="Click Here") self.button.connect("clicked", self.on_button_clicked) self.add(self.button) def on_button_clicked(self, widget): print "Hello World" win = M...

by luofeiyu_cu - Shell - 2013-02-14 20:47:35 阅读(1613) 回复(2)

test_file 测试文件内容为下面一行字符串,另外还有3个空行: .Ah "Major Heading" 目标:要把他换成@A HEAD = Major Heading,并删除后面的3个空行。 1. 我写了个脚本sedscr,执行sed -f sedscr test_file,为什么删除不掉那三个空行? /^\.Ah/{ /^$/d s/^\.Ah */@A HEAD = /g s/"//g } 2. 但是我直接命令行敲下面命令就可以删除空行sed '/^$/d' test_file 求指点,谢谢。

by Leo_Li02 - Shell - 2014-10-24 22:15:20 阅读(1483) 回复(7)

用以前那个帖子的方法 不好使

by amio555 - Shell - 2008-07-14 11:04:09 阅读(3257) 回复(14)

#!/usr/local/bin/perl system("/bin/sed '/^$/d' file6 >;file7"); 执行后提示: sed: command garbled: /^ 但是直接在命令行里执行/bin/sed '/^$/d' file6 >;file7就没有问题,请问如何解决在perl程序里可以使用^的问题。谢谢大家。

by zljjg1234 - Perl - 2005-08-08 17:11:47 阅读(6464) 回复(6)

需求:有2个以上连续的空行只保留1行,如果文件末尾有多个空行保留1个,如果没有空行就添加1个空行,我想了个,但是不知道有什么例外的情况?求测试

by justlooks - Shell - 2009-11-12 13:25:23 阅读(2948) 回复(5)

我知道可以用 sed /^$/d 删除文件中的空行,但是不能删除由空格组成的空行,如果某一行上只有几个空格,前面的命令是不能匹配该行的。 记得原来看到过删除这种空行sed命令,是匹配/^/和/$/之间没有字符的做法,可是试了一下没有成功,哪位知道的请赐教? valentine 回复于:2002-07-27 19:59:27 sed /^[ ]*$/d tt #the bracket contains a SPACE and a TAB laoju 回复于:2002-07-28 11:01:46 sed /^[[]]*$/d v...

by yangbosos - Linux文档专区 - 2009-09-29 19:18:18 阅读(1397) 回复(0)

[root@localhost local]# sed -e 's/^$//g' -e '/^[ ]$/d' 123 # !/bin/bash echo -e "frommail:\c" read f echo -e "tomail:\c" read t echo -e "sub:\c" read u echo -e "mess:\c" read m A=`cat /usr/local/$m` echo $A sendEmail -f $f -t $t -u $u -m $A exit 为什么不能把空格行删除? 谢谢

by hosuk1208 - Shell - 2008-07-10 14:34:03 阅读(2838) 回复(2)

sed删除东西是sed '/pattern/d' filename ,那我该用什么命令删除空行

by polarking - Shell - 2003-12-08 17:01:41 阅读(3516) 回复(7)

我知道可以用 sed /^$/d 删除文件中的空行,但是不能删除由空格组成的空行,如果某一行上只有几个空格,前面的命令是不能匹配该行的。 记得原来看到过删除这种空行sed命令,是匹配/^/和/$/之间没有字符的做法,可是试了一下没有成功,哪位知道的请赐教?

by binary - Shell - 2008-07-14 11:00:17 阅读(8860) 回复(23)
by 编程序了没 - Shell - 2013-11-21 15:57:08 阅读(2993) 回复(6)