I had a problem learning Linux today.
#!/bin/sh
# test.sh
username= ' HCBBT '
echo ' My name is ${username}. Call me ${username:0:1}-chan. "
This script runs directly to the Times wrong:/test.sh:5:./test.sh:bad substitution.
Toss, found that the first line of the interpreter changed to/bin/bash is no problem.
So I checked the difference between/bin/sh and/bin/bash, using: Intercept the string is not POSIX standard. The difference between SH is generally set to bash the soft chain (symlink)
Ls-l/bin/sh
lrwxrwxrwx 1 root 4 Sep 04:45/bin/sh-> Dash
In a typical Linux system (exceptions such as FREEBSD,OPENBSD, etc.), using the SH call execution script is equivalent to opening bash's
POSIX Standard mode means that/bin/sh is equivalent to/bin/bash--posix
Therefore, the differences between them come from the POSIX standard mode and bash differences, such as: intercepting the string, not using let, interrupted by the error, and so on, when used in need of attention. Reference [difference between SH and bash] http://stackoverflow.com/questions/5725296/difference-between-sh-and-bash [/bin/ The difference between bash and/bin/sh] http://www.cppblog.com/erran/archive/2012/05/24/176038.aspx [#!/bin/sh and #!/bin/bash] http:// Fanli7.net/a/bianchengyuyan/_net/20130916/424894.html