A simple example:
#!/bin/bashecho "What's your favourite star?"select var in "Leehom" "Vae" "Jay" "Jolin"; dobreak;doneecho "You have selected $var"
Running result:
root@ubuntu:~# ./star.shWhat's your favourite star?1) Leehom2) Vae3) Jay4) Jolin#? 1You have selected Leehomroot@ubuntu:~#
According to
#! /Bin/sh
Then prompt
Select: not found
Syntax error: "done" unexpected
Then, the Internet says that sh does not necessarily point to bash
Bin/sh is a soft connection. In Windows, it is equivalent to a shortcut. in Linux, soft connections do not necessarily point to bash. If soft connections point to bin/bash, bin/sh and bin/bash are the same, but if your bin/sh points to bin/CSH or bin/ksh, the bin/sh and bin/bash are the same.
Change to bash ~~
========================================================== ========================================
From: http://www.cnblogs.com/liehuzuo/archive/2012/05/08/2490249.html
#! /Bin/sh and $ bash
#! /Bin/sh indicates that the script is interpreted and executed using/bin/sh ,#! Is a special identifier, followed by the path of the shell that explains the script.
$ Bash $ indicates a system prompt, $ indicates that this user is a common user, and the Super User prompt is #.
Bash is a shell and the most common shell in Linux.
$ Bash refers to executing a subshell, Which Is Bash.
Note that "#! ", Which means that you need to specify an interpreter for executing the system file .#! It is actually a 2-byte [1] magic number, which specifies a special mark of the file type, in other words, in this case, it refers to an executable script (type man magic to get more details about this fascinating topic ). in #! Followed by a path name. this path name specifies a program that interprets commands in the script. This program can be a shell, program language, or any common program. this specified program starts from the beginning and executes the commands in the script (from #! Ignore comments. [2]
Example: 1 #! /Bin/sh 2 #! /Bin/bash 3 #! /Usr/bin/perl 4 #! /Usr/bin/TCL 5 #! /Bin/sed-F 6 #! /Usr/awk-F
Note :#! The path name provided later must be correct. Otherwise, an error message is displayed, usually "command not found", which is the only result you get when running this script.
If there is another # in the script #! Line, Bash will regard it as a normal comment line.
========================================================== ========================================================== ================================