In PHP, strings are concatenated together as follows:
$foo = "Hello";
$foo .= " World";
Here, $foo
becomes "Hello World".
How is this accomplished in Bash?
In PHP, strings are concatenated together as follows:
$foo = "Hello";
$foo .= " World";
Here, $foo
becomes "Hello World".
How is this accomplished in Bash?
I wanted to build a string from a list. Couldn't find an answer for that so I post it here. Here is what I did:
and then I get the following output:
If what you are trying to do is to split a string into several lines, you can use a backslash:
With one space in between:
This one also adds only one space in between:
You can do this too:
I prefer to use curly brackets
${}
for expanding variable in string:Curly brackets will fit to Continuous string usage:
Otherwise using
foo = "$fooWorld"
will not work.Note that this won't work
as it seems to drop $foo and leaves you with:
but this will work:
and leave you with the correct output: