CyberKeeda In Social Media

SED to remove whitespaces.



[root@localhost ~]# cat example.txt


                                   AB BC CD
                                EF FG GH
                                    HI JK LM
                                 NO PQ RS
                                TU VW XY
                                                Z

So we want to look this file as

[root@localhost ~]# cat example.txt
 AB BC CD
 EF FG GH
 HI JK LM
 NO PQ RS
 TU VW XY
 Z

To delete only the whitespaces at the beginning of one single line, use

 # sed -i 's/^ *//' example.txt

or 

# sed "s/^[ \t]*//" -i example.txt

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Designed By Kunal Saha