1. 基本知识 (1) $HOME: 当前用户的家目录 (2) `pwd`或$PWD:当前目录 (3) 脚本命名避免使用test,通过type -a test,可以查看所有匹配test的命令 gas@docker86-:~$ type test test is a shell builtin gas@docker86-:~$ type -a test test is a shell builtin test is /usr/bin/test (4) 脚本中应包含作者.时间.命令描述等信息.脚本…
1. 一个简单的例子: $ vim readname.sh #file:readname.sh#!/bin/bash echo -n "Enter your name: " read user_name if [ -n "$user_name" ] ; then echo "Hello $user_name!" exit else echo "You did not tell me your name..." exit fi…
[root@master ~]# .sh #!/bin/bash exec >> /tmp/.log >>/tmp/.log date ldkkdfkslfds date [root@master ~]# ./.sh [root@master ~]# .log Sat Jun :: UTC ./.: ldkkdfkslfds: command not found Sat Jun :: UTC Sat Jun :: UTC ./.: ldkkdfkslfds: command not…