How to concatenate string variables in Bash

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

In PHP, strings are concatenated together as follows:

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

Here, $foo becomes \"Hello World\"

30条回答
  •  旧时难觅i
    2020-11-22 04:00

    Yet another approach...

    > H="Hello "
    > U="$H""universe."
    > echo $U
    Hello universe.
    

    ...and yet yet another one.

    > H="Hello "
    > U=$H"universe."
    > echo $U
    Hello universe.
    

提交回复
热议问题