删除文件中的所有空格 - Linux
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4109589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:48:48 来源:igfitidea点击:
Remove all whitespaces in a file- Linux
提问by Yarin
How would I remove ALL whitespaces in a given file in Linux?
如何在 Linux 中删除给定文件中的所有空格?
采纳答案by Darron
Depending on your definition of whitespace, something like:
根据您对空白的定义,例如:
tr -d ' \t\n\r\f' <inputFile >outputFile
would do the trick.
会做的伎俩。
回答by mikerobi
sed 's/\s//g'|tr -d '\n'
回答by Ignacio Vazquez-Abrams
sed 's/\s//g' input.txt | tr -d '\n'
回答by tchrist
If you have UTF-8 data, best do this:
如果您有 UTF-8 数据,最好这样做:
perl -CS -pe 's/\p{Space}//g' < input > output