White space (actually, failure to quote your variables) was only part of the problem.
You can't just pipe a variable through sed
like that, it doesn't work. More precisely, it doesn't pipe the value of "$VARIABLE" through sed
, the shell will try to execute the value of "$VARIABLE" and pipe the output of that through sed
. BTW, this is not a bug - this is useful if $VARIABLE happens to contain a valid command like ls
or rsync
or whatever.
Also, if you want to assign the ouput of a command or pipeline to a variable, you need to surround that command/pipeline with $()
.
So, to modify a variable with sed
, you need to do something like this:
VARIABLE=$(printf '%s' "$VARIABLE" | sed 's/[0-9]*//g')
You could use echo
there instead of printf
but echo will interpret and act on certain character sequences in $VARIABLE (e.g. \t
, \n
, \r
, etc), while printf
won't. You'll run across a lot of examples using echo
...replace them with printf '%s'
, it's much safer.