How can I concatenate strings and variables in a shell script?
stringOne = "foo"
stringTwo = "anythingButBar"
stringThree = "? and ?"
I want to output "foo and anythingButBar"
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Nothing special, you just need to add them to your declaration.
stringOne="foo" stringTwo="anythingButBar" stringThree=$stringOne$stringTwo echo $stringThree
if you want the literal word 'and' between them:
stringOne="foo" stringTwo="anythingButBar" stringThree="$stringOne and $stringTwo" echo $stringThree
foo and anythingButBar