remove spaces in bash in file code example
Example 1: how to remove all space in file
cat file.txt | tr -d " \t\n\r"
Example 2: how to remove every space in a string in bash
#!/bin/bash
#Make our variable
var="foo bar"
#Print it without the spaces
echo ${var//[[:blank:]]/}
#Output will be foobar