删除每行空白字符 sed -i 's/^[[:space:]]*//' user.txt 删除空白行 sed -i '/^$/d' user.txt 转载于:https://www.cnblogs.com/jamespython/p/8482283.html