您的位置:首页 > 运维架构 > Shell

shell去掉空白行、多余空格

2012-04-30 15:42 453 查看
去掉空白行:

tr -s ["\012"] < test.txt > newtest.txt

sed -n '/./p' temp_file5 > newtest.txt

grep . temp_file5 > newtest.txt

grep -v '^$' temp_file5 > newtest.txt

去掉多余空格:

cat test.txt | tr -s [:space:]

sed 's/__*/_/g' test.txt
这里,_表示一个空格
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: