How to concatenate string variables in Bash

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

    I kind of like making a quick function.

    #! /bin/sh -f
    function combo() {
        echo $@
    }
    
    echo $(combo 'foo''bar')
    

    Yet another way to skin a cat. This time with functions :D

提交回复
热议问题