sed删除空行和开头的空格和tab键

[root@ob1 scripts]# cat -An tt2.txt
     1 jeyry$
     2      ^I$
     3 jfdkjfdjk$
     4 ^Ikjfdkjfdkj$
     5      klfdklfdkl$
     6 fdjkkjf dfj ^Ifkdjkjf$
     7 ^I$
     8 ffdkkjfd$

[root@ob1 scripts]# sed -rn '/^[ \t]*$/!s#^[ \t]*##gp' tt2.txt
jeyry
jfdkjfdjk
kjfdkjfdkj
klfdklfdkl
fdjkkjf dfj  fkdjkjf
ffdkkjfd

==============================================

[root@ob1 scripts]# cat -An tt2.txt
     1 jeyry$
     2      ^I$
     3 jfdkjfdjk$
     4 ^Ikjfdkjfdkj$
     5      klfdklfdkl$
     6 fdjkkjf dfj ^Ifkdjkjf$
     7 ^I$
     8 ffdkkjfd$
     9 $
    10 $
    11 dfyufudjhdf$
    12    $
    13 jkfjkdf$
    14      $
[root@ob1 scripts]# sed -rn '/^[ \t]*$/!s#^[ \t]*##gp' tt2.txt
jeyry
jfdkjfdjk
kjfdkjfdkj
klfdklfdkl
fdjkkjf dfj  fkdjkjf
ffdkkjfd
dfyufudjhdf
jkfjkdf

posted @ 2017-09-20 10:10  滴滴滴  阅读(2777)  评论(0编辑  收藏  举报