bash remove trailing whitespace from every line code example
Example 1: bash remove trailing whitespace from every line
# Basic syntax:
awk '{$1=$1};1' your_file
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