echo " lol " | xargs echo " this string has a lot of spaces " | xargs echo -n Produces: 'this string has a lot of spaces' https://stackoverflow.com/questions/369758/how-to-trim-whitespace-from-a-bash-variable How to trim whitespace from a Bash variable? I have a shell script with this code: var=`hg st -R "$path"` if [ -n "$var" ]; then echo $var fi But the conditional code always executes, becau..