您的位置:首页 > 运维架构 > Shell

常用经典shell脚本整理

2017-01-22 10:55 218 查看
常用经典shell脚本整理
发表于: Linux, Shell, UNIX, 运维经验 | 作者: 谋万世全局者标签: Shell,常用,经典,脚本1.check_user.sh #!/bin/bashecho "You are logged in as `whoami`";if [ `whoami` != linuxtone ]; thenecho "Must be logged on as linuxtone to run
this script."exitfiecho "Running script at `date`"2.do_continue.sh #!/bin/bashdoContinue=necho "Do you really want to continue?
(y/n)"read doContinueif [ "$doContinue" != y ]; thenecho "Quitting..."exitfiecho "OK... we will continue."3.hide_input.sh #!/bin/bashstty -echoecho -n "Enter the database system password: "read pwstty echoecho "$pw was entered" 4.is_a_directory.sh #!/bin/bashif [ -z "$1" ]; thenecho ""echo " ERROR : Invalid number of
arguments"echo " Usage : $0 "echo ""exitfiif [ -d $1 ]; thenecho "$1 is a directory."elseecho "$1 is NOT a directory."fi 5.is_readable.sh #!/bin/bashif [ -z "$1" ]; thenecho ""echo " ERROR : Invalid number of
arguments"echo " Usage : $0 "echo ""exitfiif [ ! -r $1 ]; thenecho "$1 is NOT readable."elseecho "$1 is readable."fi 6.print_args.sh #!/bin/bash## The shift command removes the argument nearest# the command name and replaces it with the next one#while [ $# -ne 0 ]doecho $1shiftdone永久链接 : http://www.ha97.com/4020.html Pasted
from <http://www.ha97.com/4020.html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell Linux