批处理之家's Archiver

netdzb 发表于 2019-7-1 07:59

sed 命令如何把windows格式的空行去掉

linux格式的空行,我能去掉了。
windows格式的,执行命令还是原来的。
不知道怎么弄了。

cfwyy77_bat 发表于 2019-7-1 08:44

[code]sed -E '/^($|\r)/d' file[/code]

netdzb 发表于 2019-7-1 09:29

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=221530&ptid=53211]2#[/url] [i]cfwyy77_bat[/i] [/b]


  sed -E '/^($|\r)/d' tyre.txt     #  这样tyre.txt并没有被改写

sed -E '/^($|\r)/d' tyre.txt > vv.txt   # 这样文件被改写到vv.txt,
原档tyre.txt并没有被改写。怎么直接改到tyre.txt上呢?

Batcher 发表于 2019-7-1 09:37

[b]回复 [url=http://bbs.bathome.net/redirect.php?goto=findpost&pid=221532&ptid=53211]3#[/url] [i]netdzb[/i] [/b]


    sed [color=Red]-i[/color] -E

cfwyy77_bat 发表于 2019-7-1 09:48

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=221532&ptid=53211]3#[/url] [i]netdzb[/i] [/b]


    加 -i 参数 。既然要用sed,   sed  --help总要看一看吧{:3_53:}

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.