Shell how to concatenate strings in a macro

Hello all.

I have a throuble when I try to concatenate some strings in a shell script macro.
The script uses sh.
Code:
root@freebsd:~ # sh
[B]# name="john"
# name+=" doe"[/B]
name+=doe: not found
#
Can anyone identify where is mistake?
 
Last edited by a moderator:
I thought that the commands and syntax of SH was similar to Bash.
It's the other way around, Bash syntax is similar to the Bourne Shell (it existed long before bash).

And there's a difference between the Bourne shell and the Bourne Again Shell (bash). While technically on FreeBSD /bin/sh is the Almquist Shell.

https://en.wikipedia.org/wiki/Almquist_shell
https://en.wikipedia.org/wiki/Bourne_shell
https://en.wikipedia.org/wiki/Bash_(Unix_shell)

I use this site a lot for reference: http://www.grymoire.com/Unix/Sh.html. Stick to that and your script will work on all three shells.
 
Back
Top