Trim leading and trailing whitespace: sed -i 's/^[ \t]*//;s/[ \t]*$//' somefile

[root@localhost ~]# cat filedate
    Wed Jun 28 11:23:31 EDT 2017
   ffdfd fdf
  ffdf  fdfd
         fdf    ffdfdfd  dfd  
  ds
 d

 ddsd


[root@localhost ~]# sed -i 's/^[ \t]*//;s/[ \t]*$//' filedate && cat filedate 
Wed Jun 28 11:23:31 EDT 2017
ffdfd fdf
ffdf  fdfd
fdf    ffdfdfd  dfd
ds
d

ddsd

Comments

Popular posts from this blog

HAproxy logging

tomcat catalina coyote jasper cluster

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all