• Shell 脚本面试问题大全

    日期:

    我们为你的面试准备选择了 70 个你可能遇到的 shell 脚本面试问题及解答。了解脚本或至少知道基础知识对系统管理员来说至关重要,它也有助于你在工作环境中自动完成很多任务。在过去的几年里,我们注意到所有的 linux 工作职位都要求脚本技能。 1) 如何向脚...

  • 一个Linux中用于监控的简易shell脚本

    日期:

    系统管理员的任务真的很艰难,因为他/她必须监控服务器、用户、日志,还得创建备份,等等等等。对于大多数重复性的任务,大多数管理员都会写一个自动化脚本来日复一日地重复这些任务。这里,我们已经写了一个shell脚本给大家,用来自动化完成系统管理员所要...

  • shell无密钥脚本

    日期:

    ##### 批量部署ssh私钥认证 ##### 一、首先安装expect,直接yum即可 二、批量部署ssh私钥脚本 batch_sshkey.sh ============================================================== #!/bin/bash cd /root cat /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys...

  • Linux shell 命令判断执行语法 ; , && , ||

    日期:

    连续执行用分号 通过变量$?来判断执行 快捷判断语法 和 || 连续执行用分号 有时候我们想要在命令行下,写下多条命令。这时候该怎么操作呢。如下所示: #ls /tmp/xxxx ; echo /tmp/xxxxls: /tmp/xxxx: No such file or directory/tmp/xxxx 一般/tmp/目录下,...

  • linux shell判断目录是否为空的函数

    日期:

    linux shell判断目录是否为空的函数: Folder_DEPLOY=/home/user/log #判断目录是否为空的函数 function checkDerectory() { if [ `ls -A $Folder_DEPLOY` = ]; then //do something echo true else //do something echo false fi } 调用函数: shell部分: d...

  • Linux shell 时间操作(取昨天 前天等)

    日期:

    1. 取今天时间 Shell代码 $date-d now +%Y-%m-%d 2. 取昨天时间 Shell代码 $date-d yesterday +%Y-%m-%d $date-d 1daysago +%Y-%m-%d ## -d, --date=STRING display time described by STRING, not `now STRING可以为now 、 yesterday、 n days ago n days a...

  • linux shell 判断文件是否存在

    日期:

    #!/bin/sh # 判断文件是否存在 # link:www.jb51.net # date:2013/2/28 myPath=/var/log/httpd/ myFile=/var /log/httpd/access.log # 这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if [ ! -x $myPath]; then mkdir $myPath fi # 这里的-d 参数...

  • Linux shell编程——if条件判断

    日期:

    if 语句格式 if 条件 then Command else Command fi 别忘了这个结尾 If语句忘了结尾fi test.sh: line 14: syntax error: unexpected end of fi if 的三种条件表达式 if command then if 函数 then 命令执行成功,等于返回0 (比如grep ,找到匹配) 执行失败...

  • 脚本实现实时显示linux网络流量

    日期:

    vim flow.sh 1234567891011121314151617181920212223242526272829303132 #!/bin/bash #caishzh 20121030 #displays the current Traffic ETH = $1 ETH = ${ETH:-eth0} IP = ` ifconfig $ETH | awk -F [ :]+ /inet addr/{print $4} ` while true ; do let I+=...

  • 『总结』shell算数运算方法

    日期:

    1.expr 表达式 expr只能用于一元操作符,不支持二元操作符 12 x = 1 x =$ ( expr $x + 1 ) $x + 1之间必须有空格 2.let 表达式 1234 x = 10 let x = $x + 1 let x+= 1 let x * = 10 3.使用$((表达式)) 1 x =$ ( ( 4 + 5 ) ) 4.使用$[ ]形式 1 x =$ [ 4 + 5 ]...