How to concatenate string variables in Bash

后端 未结 30 1919
攒了一身酷
攒了一身酷 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:04

    Bash also supports a += operator as shown in this code:

    A="X Y"
    A+=" Z"
    echo "$A"
    

    output

    X Y Z

提交回复
热议问题