Bash(GNU Bourne-Again Shell)is a Unix shell and script language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. First released in 1989, it has been used as the default login shell for most Linux distributions.
〇、从“Hello World”程序开始!
下面是一个简单的“Hello World”程序,但是我们利用一个while循环来执行5次字符串输入语句(如何编写循环语句,我们会在后续文章中详细解释):
x=1
while [ $x -le 5 ]
do
echo "Hello World"
x = $(($x+1))
done
编辑好脚本文件(例如脚本文件名为mybash1.sh)之后,在命令行窗口使用sh mybash1.sh可以执行该脚本程序,如下图所示:
With bash, use -x to echo commands before they are executed and -n to check commands for syntax without executing them. 例如: