How to concatenate string variables in Bash

后端 未结 30 1477
攒了一身酷
攒了一身酷 2020-11-22 03:40

In PHP, strings are concatenated together as follows:

$foo = \"Hello\";
$foo .= \" World\";

Here, $foo becomes \"Hello World\"

30条回答
  •  隐瞒了意图╮
    2020-11-22 04:19

    If it is as your example of adding " World" to the original string, then it can be:

    #!/bin/bash
    
    foo="Hello"
    foo=$foo" World"
    echo $foo
    

    The output:

    Hello World
    

提交回复
热议问题