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 ex
In order to remove all the spaces from the beginning and the end of a string (including end of line characters):
echo $variable | xargs echo -n
This will remove duplicate spaces also:
echo " this string has a lot of spaces " | xargs echo -n
Produces: 'this string has a lot of spaces'