1)删除行首空格
sed ‘s/[ \t]*//g’

替换字符串的空格

2)删除行尾空格
sed ‘s/[ \t]*$//g’
3)删除所有空格
sed s/[[:space:]]//g

替换字符串的空格

替换字符串的空格

4)去除文件的空白行

替换字符串的空格

相关文章: