[root@hanfeng ~]# mkdir shell [root@hanfeng ~]# cd shell/ [root@hanfeng shell]#
[root@hanfeng shell]# vi 01.sh #! /bin/bash //固定格式 echo "123" w ls 保存退出
[root@hanfeng shell]# sh 01.sh 123 22:45:12 up 14 min, 1 user, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root pts/0 22:32 0.00s 0.05s 0.03s w 01.sh [root@hanfeng shell]#
[root@hanfeng shell]# chmod a+x 01.sh [root@hanfeng shell]#
7執行shell腳本 ./01.sh 能這樣執行,說明這些命令被解析了,被/bin/bash認識了shell
[root@hanfeng shell]# ./01.sh 123 23:11:21 up 41 min, 1 user, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root pts/0 22:32 1.00s 0.05s 0.00s /bin/bash ./01.sh 01.sh [root@hanfeng shell]#
[root@hanfeng shell]# ls -l /bin/bash -rwxr-xr-x. 1 root root 960368 6月 10 2014 /bin/bash [root@hanfeng shell]# ls -l /bin/sh lrwxrwxrwx. 1 root root 4 10月 21 00:47 /bin/sh -> bash [root@hanfeng shell]#
[root@hanfeng shell]# /bin/bash 01.sh 123 23:21:43 up 51 min, 1 user, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root pts/0 22:32 7.00s 0.03s 0.00s w 01.sh [root@hanfeng shell]#
[root@hanfeng shell]# /root/shell/01.sh 123 23:45:02 up 1:14, 1 user, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root pts/0 22:32 6.00s 0.03s 0.00s w 01.sh [root@hanfeng shell]#
[root@hanfeng shell]# sh -x 01.sh + echo 123 123 + w 23:47:35 up 1:17, 1 user, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root pts/0 22:32 7.00s 0.03s 0.00s sh -x 01.sh + ls 01.sh [root@hanfeng shell]#
[root@hanfeng shell]# sh -n 01.sh [root@hanfeng shell]#