#!/bin/bash set -eux mysqld >& & CONNECTED=$(netstat -alnt | grep -c ":3306 ") ]; do echo "MYSQL NOT CONNECTED YET"; sleep ; CONNECTED=$(netstat -alnt | grep -c ":3306 ") done mysql -uroot -p"${MYSQL_ROOT_PASS…
/************************************************************************* * Linux Shell 判断块设备节点是否存在 * 说明: * 能牌问shell脚本-f不能判断mmc设备节点的问题,查了一下资料,发现不能 * 使用-f来判断,要使用-e或者-b来判断才行. * * 2017-1-17 深圳 南山平山村 曾剑锋 *************************************************…
shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if [ ! -x "$myPath"]; then mkdir "$myPath" fi #这里的-d 参数判断$myPath是否存在 if [ ! -d "$m…
shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if [ ! -x "$myPath"]; then mkdir "$myPath" fi #这里的-d 参数判断$myPath是否存在 if [ ! -d "$m…
在linux中判断文件,目录是否存在或则具有的权限,根据最近的学习以及网上的资料,进行了以下的总结: #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if [ ! -x "$myPath"]; then mkdir "$myPath" fi #这里的-d 参数判断$m…
需求描述: 在写shell脚本的时候,会有这样的需求,脚本在执行的过程中是需要传入参数的,如果没有参数传递给脚本, 就会给出相应的脚本使用方法或者例子,告知,脚本后面应该加什么样的参数.所以呢,这里要做的就是如何 知道当前传递给脚本的参数的数量,如果是0个,就执行使用说明的显示. 实现方法: 脚本中通过$#来判断,当前传递给脚本的参数的数量. 测试脚本: #!/bin/bash echo $# 测试过程: 分别传入多个参数,并且执行脚本,查看执行的结果. [root@redhat6 ~]# ./…
1.判断字符串为空 if [ -z "$str" ]; then echo "empty string" fi 2.判断文件是否存在 if [ -f /home/builder/.profile ]; then echo "File exists;" fi 3.逻辑非 if [ ! -f /home/builder/.bash_profile ]; then   echo "here!"else   echo "te…
工作中会遇到验证到某某服务器端口是否连通,如果IP或端口多时,用shell还是很省时省力的,看下面的脚本: #!/bin/bash # #database check #set -o nounset LOCALIP=`ifconfig | grep inet | head - | awk '{print $2}' | sed 's/addr\://'` IPLIST='192.168.161.234192.168.161.235192.168.161.22' PORTLIST='1521 152…
由于需要,需要将一系列mysql的操作制作成.sh文件,只需要shell操作bash命令就可以傻瓜式的完成黑盒任务. #!/bin/bash mysql -uroot -p??? -e "create database IF NOT EXISTS test_db_test" mysql -uroot -p??? -e "use test_db_test;create table IF NOT EXISTS test_table_test ( name varchar(20),…
#--------------------------Mysqldump异地备份-----------------# #!/bin/bash #start mysqldump back /usr/bin/mysqldump -uroot -pP@ssw0rd discuz > $(date +%Y%m%d)-discuz.sql #start tar tar -zcvf $(date +%Y%m%d)mysql.tar.gz ./$(date +%Y%m%d)* #start ftp ftp -…