Below is a complete copy of a demo I'm using to to figure out to get the sed
command to get rid of the spaces in a persons name, and compress it down to not have spaces.
Once this is done, I want to assign it to the variable comp
then I can re-use it later on in the script. Here I am just trying to echo
it to the stdout so I can see it worked.
If I run the script and enter my name as Ronald McDonald
the result I get returned is RonaldMcDonald}
with that curly brace on the end of his name, or whatever I type in.
How do I get it to work, so that the result doesn't append the }
to the back of the assigned text.
#!/bin/bash
function readName {
echo "Enter your full name:"
read fullName
clear
} # end readName
function cmprsName {
comp={ echo "$fullName" } | sed 's/ //g'
} # end cmprsName
function sayItNow {
echo $comp
} # end sayItNow
function allTogether {
readName
cmprsName
sayItNow
} #end allTogether
case $1 in
-h | --help ) allTogether
exit
;;
* ) echo "$0 -h"
exit 1
esac
$(..)
syntax is preferred to the older\
..`` syntax for reasons of readability and nesting. – evilsoup Oct 05 '13 at 14:51