Wednesday, January 23, 2013

Some SED tips for my records

To delete trailing whitespace from end of each line:
# sed 's/[ \t]*$//' filename > filename_notrailingspace

To remove all blank lines:
# sed '/^$/d' filename > filename_noblankspace

To remove all leading and trailing whitespace from end of each line:
$ cat filename | sed 's/^[ \t]*//;s/[ \t]*$//' > filename_nospace

Popular Posts

About Me

My photo
The intent of this blog is to share my work experience and spread some smart solutions on Linux to System Administrators. I'm hoping the solutions shared in this Blog would be helpful and come as a handy for Viewers. Brief about me: I have 18+ years work experience in System and Cloud Administration domain, primarily works on VMware Cloud Products (vSphere, vCloud Director, vRealize Automation, NSX Adv. Load Balancer, vROps).