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
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
Post a Comment