查看当前系统环境变量 cat test2: #!/bin/bash # display user information from the system. echo "User info for userid:$USER" echo UID:$UID echo HOME:$HOME 添加执行权限:chmod u+x test2 运行:./test2 结果如下: User info for userid:clarck UID: HOME:/home/clarck
查看当前日期以及登陆用户: cat test1: #!/bin/bash # This script displays the date and who's logged on echo -n The time and date are: date echo "Let's see who's logged into the system:" who 添加执行权限:chmod u+x test1 执行./test1,得带结果如下: The :: CST Let's see who's l
#!/bin/bash dir=`ls /root//*` for i in $dir do #basename 返回一个字符串参数的基本文件名称.(只剩下文件名除去路径名) a=`basename $i` cd /root// r=`find . -name "$a"` if [ "$r"x == "./$a"x ]; then continue else scp -r $i root@ fi done