Script test.sh content:
#!/bin/bash
Read Presskeyindexes=0c=${presskey:indexes:1} is executed using debug mode: Sh-x test.sh 3rd line always appears bad substitution prompt information. Best of all: So Baidu, find a useful information, which is used by the Linux shell is/bin/sh, or/bin/bash has a relationship. The/bin/bash shell is specified in my script, but I use the SH shell when I debug, so I debug with an error message. Workaround: Use bash-x test.sh for debugging, then success. The following is a reference to the linked content: Http://hi.baidu.com/wwkblog/item/c974569b9ee031aecd80e5fe
It is always an error to execute the following script on LinuxMint:
123 |
#!bin/sh a= "abcdefghijklmn" echo ${a:2:7} |
Then run SH 1.sh always quote bad substitutation
Later changed into
123 |
#!bin/bash a= "abcdefghijklmn" echo ${a: 2 : 7 } |
Then execute bash 1.sh with no problem.
The reason is that Ubuntu sh is connected to dash instead of bash, and naturally in identifying ${a:2:7} always goes wrong.
There are several types of shells in the
linux, the most common of which are Bourne shell (SH), c Shell (CSH) and Korn shell (Ksh). Each of the three shells has advantages and disadvantages. Bourne shell is the first shell used by UNIX and can be used on every UNIX type. Bourne shell is very good at Shell programming, but does not work as well as several other shells in dealing with user interactions. Linux OS default shell is Bourne again shell, it is the extension of Bourne shell, For short, bash is completely backwards compatible with Bourne shell and adds and enhances many features on the basis of Bourne shell. Bash is placed in/bin/bash, which has many features, such as command completion, command editing, and command history tables, and it also contains a lot of C shell and korn The advantages of the shell are flexible and powerful programming interfaces while having a friendly user interface.
/bin/sh in the Gnu/linux operating system is a symbolic link to bash (Bourne-again Shell), but given that bash is too complex, someone transplanted ash from NetBSD to Linux and renamed it dash (Debian Almquis T Shell), and it is recommended to point/bin/sh to it for faster script execution. Ubuntu claims that since they did so in the 6.10 edition, the system boot speed has been significantly improved. The Debian program also takes dash as the default/bin/sh in the next release (codenamed Lenny).
Linux shell script execution error: bad substitution