How to concatenate string variables in Bash

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

    Here is the one through AWK:

    $ foo="Hello"
    $ foo=$(awk -v var=$foo 'BEGIN{print var" World"}')
    $ echo $foo
    Hello World
    

提交回复
热议问题