Concatenate string variables in Bash

David Y.

The Problem

How can I concatenate string variables in Bash?

The Solution

You can use the substitution syntax (${}) as follows:

h="Hello" w="world" hw="${h} ${w}" echo $hw # will output "Hello world"
Join the discussionCome work with us
Share on Twitter
Bookmark this page
Ask a questionImprove this Answer

Related Answers

A better experience for your users. An easier life for your developers.

    TwitterGitHubDribbbleLinkedin
© 2023 • Sentry is a registered Trademark
of Functional Software, Inc.