Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all whitespaces in a file- Linux

How would I remove ALL whitespaces in a given file in Linux?

like image 860
Yarin Avatar asked Nov 05 '10 20:11

Yarin


People also ask

How do I remove all spaces in a text file?

Press Shift + Alt then press the down button before "56". Then backspace . You will see the cursor becomes big and then you can remove the spaces all at once.

How do I get rid of whitespaces?

The replaceAll() method of the String class replaces each substring of this string that matches the given regular expression with the given replacement. You can remove white spaces from a string by replacing " " with "".


1 Answers

Depending on your definition of whitespace, something like:

tr -d ' \t\n\r\f' <inputFile >outputFile 

would do the trick.

like image 117
Darron Avatar answered Oct 14 '22 14:10

Darron