[dywang@dywmac zzz]$ cd [dywang@dywmac ~]$ cd zzz [dywang@dywmac zzz]$ vim sh01.sh [dywang@dywmac zzz]$ cat sh01.sh #!/bin/bash # Program: # This program is used to show "Hello World !" in screen. # History: # 2019/04/25 dywang First release echo -e "Hello World ! \a \n" exit 0
#!
是用來宣告 shell 外,其他的 #
都是『註解』。
\
跳脫字元。
\a
為警告;\n
為換行。
$?
觀察回傳值。
[dywang@dywmac zzz]$ sh sh01.sh Hello World !
[dywang@dywmac zzz]$ echo $? 0
[dywang@dywmac zzz]$ chmod +x sh01.sh [dywang@dywmac zzz]$ ./sh01.sh Hello World !