Remove all whitespaces in a file- Linux
71,565
Solution 1
Depending on your definition of whitespace, something like:
tr -d ' \t\n\r\f' <inputFile >outputFile
would do the trick.
Solution 2
sed 's/\s//g' input.txt | tr -d '\n'
Solution 3
sed 's/\s//g'|tr -d '\n'
Solution 4
If you have UTF-8 data, best do this:
perl -CS -pe 's/\p{Space}//g' < input > output
Author by
Yarin
Products PDF Buddy - Popular online PDF editor Gems Snappconfig - Smarter Rails app configuration
Updated on January 14, 2020Comments
-
Yarin over 4 years
How would I remove ALL whitespaces in a given file in Linux?