Showing posts with label hello world. Show all posts
Showing posts with label hello world. Show all posts

Sunday, April 27, 2014

Bash String Concatenation

If you writing Bash scripts, it's probably happened that you need to concatenate two or more strings. There are several ways to do this:

1. Variable insert

$ a="Hello"
$ b="$a World"
$ echo $b
Hello World

2. Writing variables one after another

$ a="Hello"
$ b=" World"
$ c=$a$b
$ echo $c
Hello World

3. Using += operator

$ a="Hello"
$ a+=" World"
$ echo $a
Hello World