工作学习日志(shell -file)
2016-11-18 00:00
295 查看
摘要: 用shell读取文件,循环显示每一行内容
大家应该能看懂下面,附上文件内容:
[new]
20161109111001_*****.sql
[old-game-2016.10.29]
20161109111001_*****.sql
#类型: 内部函数
function __updateSqlBlock() {
local config_name=$1
local db_url=$2
local db_username=$3
local db_password=$4
file='./config/update_sql_info.conf'
read_tag=0
while read line
do
row=`echo $line | grep '\[' | sed 's/\[//g' | sed 's/\]//g'`
if [ "$row" == 'new' ];then
read_tag=1
fi
is_old=`echo $row | grep 'old' `
if [ "$is_old" != "" ];then
read_tag=0
fi
if [ "$read_tag" -eq "1" ];then
if [ "$row" != 'new' ] && [ "$line" != "" ] ;then
echo "mysql -h$db_url -u$db_username -p$db_password $config_name < /var/www/$config_name/sql/migrations/$line"
fi
fi
done < $file
}
大家应该能看懂下面,附上文件内容:
[new]
20161109111001_*****.sql
[old-game-2016.10.29]
20161109111001_*****.sql
#类型: 内部函数
function __updateSqlBlock() {
local config_name=$1
local db_url=$2
local db_username=$3
local db_password=$4
file='./config/update_sql_info.conf'
read_tag=0
while read line
do
row=`echo $line | grep '\[' | sed 's/\[//g' | sed 's/\]//g'`
if [ "$row" == 'new' ];then
read_tag=1
fi
is_old=`echo $row | grep 'old' `
if [ "$is_old" != "" ];then
read_tag=0
fi
if [ "$read_tag" -eq "1" ];then
if [ "$row" != 'new' ] && [ "$line" != "" ] ;then
echo "mysql -h$db_url -u$db_username -p$db_password $config_name < /var/www/$config_name/sql/migrations/$line"
fi
fi
done < $file
}
相关文章推荐
- 工作学习日志(shell)
- 工作学习日志(shell)
- 工作学习日志(shell-ruby-gem)
- 【工作日志】【02】【asp学习】北风网 李炎恢 网易云课堂 asp教程 笔记
- Cocos2d-x 3.1.1 学习日志17--移植出现error C1083: 无法打开包括文件:“extensions/ExtensionMacros.h”: No such file or
- 通过实践学习Shell(做腾讯百度淘宝shell面试题 以及切割分析日志)
- oracle dba 学习日志1(controlfile,tablespace)
- Shell脚本学习笔记(八)--进程管理和工作控制
- shell学习日志
- shell学习:Linux系统日志的相关命令、文件和管理工具
- 系统架构学习日志2-Log structured vs Journaling File System
- Cocos2d-x 3.1.1 学习日志17移植出现error C1083: 无法打开包括文件:“extensions/ExtensionMacros.h”: No such file or
- shell学习日志
- Cocos2d-x 3.1.1 学习日志17移植出现error C1083: 无法打开包括文件:“extensions/ExtensionMacros.h”: No such file or
- 工作中shell命令分析Apache网站日志大全
- Cocos2d-x 3.1.1 学习日志17移植出现error C1083: 无法打开包括文件:“extensions/ExtensionMacros.h”: No such file or
- 2010-12-11 组长工作日志概要设计的开发学习
- 06月02日,工作学习日志
- shell脚本学习日志
- Shell 简单学习 (工作随记)