In PHP, strings are concatenated together as follows:
$foo = \"Hello\";
$foo .= \" World\";
Here, $foo
becomes \"Hello World\"
I don't know about PHP yet, but this works in Linux Bash. If you don't want to affect it to a variable, you could try this:
read pp; *# Assumes I will affect Hello to pp*
pp=$( printf $pp ;printf ' World'; printf '!');
echo $pp;
>Hello World!
You could place another variable instead of 'Hello' or '!'. You could concatenate more strings as well.
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
If what you are trying to do is to split a string into several lines, you can use a backslash:
$ a="hello\
> world"
$ echo $a
helloworld
With one space in between:
$ a="hello \
> world"
$ echo $a
hello world
This one also adds only one space in between:
$ a="hello \
> world"
$ echo $a
hello world
foo="Hello "
foo="$foo World"
The way I'd solve the problem is just
$a$b
For example,
a="Hello"
b=" World"
c=$a$b
echo "$c"
which produces
Hello World
If you try to concatenate a string with another string, for example,
a="Hello"
c="$a World"
then echo "$c"
will produce
Hello World
with an extra space.
$aWorld
doesn't work, as you may imagine, but
${a}World
produces
HelloWorld
Here is the one through AWK:
$ foo="Hello"
$ foo=$(awk -v var=$foo 'BEGIN{print var" World"}')
$ echo $foo
Hello World