Checkout Linux utilities awk and sed to manipulate text on the command line. This post discusses with examples how to use sed and awk to remove space in text or strings.
Source: LXer – Remove White Space In Text or String Using Awk and Sed In Linux