Remove whitespace from a string in bash
If the file /etc/foo.props contained:
context-root= /app1 http_port= 8080 admin-port= 9090
... and you were using
http_port=$(cat /foo/props.conf | grep http-port | cut -d = -f 2
$http_port would end up being prefixed by whitespace, which would be a problem if you were using this to construct a URL in a script. To resolve this, you could use xargs as follows:
http_port=$(cat /etc/foo.props | grep http-port | cut -d = -f 2 | xargs)