hellopasswdshell
[root@localhost ~]# mkdir shell [root@localhost ~]# cd shell/ [root@localhost shell]# vi 1.sh 添加 1 #!/bin/bash 2 echo "1" 3 w 4 ls
執行腳本方式bash
[root@localhost shell]# sh 1.sh [root@localhost shell]# sh 1.sh 1 04:37:40 up 17:50, 2 users, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root tty1 Fri10 16:41m 1.01s 1.01s -bash root pts/1 04:24 4.00s 0.04s 0.00s /bin/bash ./1.sh 1.sh
[root@localhost shell]# chmod a+x 1.sh [root@localhost shell]# ./1.sh 1 04:41:23 up 17:54, 2 users, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root tty1 Fri10 16:44m 1.01s 1.01s -bash root pts/1 04:24 3.00s 0.08s 0.00s /bin/bash ./1.sh 1.sh
[root@localhost shell]# sh -x 1.sh + echo 1 1 + w 04:44:30 up 17:57, 2 users, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root tty1 Fri10 16:47m 1.01s 1.01s -bash root pts/1 04:24 6.00s 0.13s 0.02s w + ls 1.sh
每個+表示執行的過程.net
判斷語法是否存在錯誤code
[root@localhost shell]# sh -n 1.sh
[root@localhost ~]# date Sat Feb 3 06:25:06 EST 2018 [root@localhost ~]# date +%Y 2018 [root@localhost ~]# date +%m 02 [root@localhost ~]# date +%d 03
[root@localhost ~]# date +%Y-%m-%d 2018-02-03 [root@localhost ~]# date +%y-%m-%d 18-02-03 [root@localhost ~]# date +%F 2018-02-03
[root@localhost ~]# date +%F 2018-07-17
[root@localhost ~]# date +%T 05:30:29
[root[@localhost](https://my.oschina.net/u/570656) ~]# date +%H:%M:%S 06:31:15 [root[@localhost](https://my.oschina.net/u/570656) ~]# date +%T 06:31:30
[root@localhost ~]# date -d "-1 day" +%y%m%d 180202 [root@localhost ~]# date -d "+1 day" +%y%m%d 180204 [root@localhost ~]# date -d "-1 month" +%y%m%d 180103 [root@localhost ~]# date -d "-1 min" +%H%M%S 062741
years、month、day、hour、min、date
[root@localhost ~]# date +%w 6 [root@localhost ~]# date +%W 05
[root@localhost ~]# cal February 2018 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 [root@localhost ~]# cal 2018 2018 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 1 2 3 1 2 3 7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10 14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17 21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24 28 29 30 31 25 26 27 28 25 26 27 28 29 30 31 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 1 2 3 4 5 1 2 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16 22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23 29 30 27 28 29 30 31 24 25 26 27 28 29 30 July August September Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 1 2 3 4 1 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15 22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29 30 October November December Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 1 2 3 1 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 30 31
[root@localhost ~]# date +%s 1517661538
[root@localhost ~]# date -d @1517661538 Sat Feb 3 07:38:58 EST 2018 [root@localhost ~]# date +%s -d "2018-02-03 07:38:58" 1517661538
修改於 180205語法