Shell脚本中获取select值
最近做一个数据清理,根据行号清理,所以需要查出这个行的最大最小值出来进行删除,如果靠手动每次去查,太麻烦所以就用在sh脚本当中执行SELECT语句,并将结果赋值给一个变量。
sh脚本如下
#! /bin/sh
echo "Please enter the bankseq: \c"
read bankseq
echo "do you confirm enter the bankseq Y/N : " ;
read result ;
if [ "Y" = ${result} -o "y" = ${result} ]
then
i=;
usq_add_max=; #userseq增加值
db2 connect to xxx
dd=`db2 "select min(userseq),max(userseq) from puser where bankseq=$bankseq"`;
usq_min=`echo $dd|awk '{print $5}'`
usq_max=`echo $dd|awk '{print $6}'`
while((i<=));
do
i=$i+;
usq_add_max=$(($usq_min+));
if [ $usq_add_max -gt $usq_max ]
then
usq_add_max=$usq_max;
fi
db2 "delete from (select * from PUSERCERT where userseq <= $usq_add_max and userseq >= $usq_min and userseq in (select userseq from PUSER_TMP where bankseq=$bankseq))" >> Clear1_PUSERCERT.log
usq_min=$(($usq_min+));
done;
fi
说明
sh脚本查询出来赋值不好赋值,所以只能用到AWK处理文本文件的语言,进行截取。
Shell脚本中获取select值的更多相关文章
- [转]Shell脚本中获取SELECT结果值的方法
http://blog.itpub.net/13885898/viewspace-1670297/ 有时候我们可能会需要在Shell脚本中执行SELECT语句,并将结果赋值给一个变量,对于这样的情形, ...
- shell脚本中获取当前所在目录地址
shell脚本中获取当前所在目录如下 #!/bin/bash work_path=$() cd ${work_path} work_path=$(pwd) cd ${work_path}/src
- linux,shell脚本中获取脚本的名字,使用脚本的名字。
需求描述: 写shell脚本的过程中,有时会需要获取脚本的名字,比如,有的时候,脚本 中会有usage()这种函数,可能就会用到脚本的名字. 实现方法: shell脚本中,通过使用$0就可以获取到脚本 ...
- Linux Shell脚本中获取本机ip地址方法
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:" 命令解释 ...
- 如何在shell脚本中获取当前用户名?
答:使用环境变量USER即可 如在脚本中打印当前用户名; #!/bin/sh echo "user name = ${USER}"
- shell脚本中case select 的使用
#!/bin/bash # case echo "1.Install PHP" echo "2.Install Mysql" echo "3.Inst ...
- shell脚本中获取本机ip地址的方法
ipaddr='172.0.0.1' ipaddr=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/ ...
- 在Shell脚本中获取指定进程的PID
注意这条命令用反引号(Tab上面的那个键)括起来,作用类似于${ } processId = ` ps -ef | grep fms.jar | grep -v grep | awk '{print ...
- shell脚本中select循环语句用法
shell脚本中select循环语句 1. 脚本中select的语法格式 select VAR in LIST do command1 command2 ... ... commandN done s ...
随机推荐
- Linux系统的shell是什么
shell是用户和Linux操作系统之间的接口.Linux中有多种shell,其中缺省使用的是Bash.本章讲述了shell的工作原理,shell的种类,shell的一般操作及Bash的特性. 什么是 ...
- MTK如何烧录IMEI码(俗称串号)
先介绍一下使用环境 主控:MT6582VX android版本:4.4.2 操作系统:windows XP SN烧录工具:SN_Write_tool_exe_v2.1420.00 首先介绍一下IMEI ...
- HBase集群部署脚本
#!/bin/bash # Sync HBASE_HOME across the cluster. Must run on master using HBase owner user. HBASE_H ...
- android EventBus详解(三)
post()方法调用流程 我们继续来看EventBus类,的另一个入口方法post() //已省略部分代码 public void post(Object event) { PostingThread ...
- javascript、ruby和C性能一瞥(3) :上汇编
在博文(1)和(2)里分别用了4中方式写一个素数筛选的算法,分别是javascript in browser.node.js.ruby和c:最终的结果是c最快,node.js其次,js in b虽然也 ...
- LeetCode(25)-symmetric tree
题目: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). F ...
- Spring Cloud项目中通过Feign进行内部服务调用发生401\407错误无返回信息的问题
问题描述 最近在使用Spring Cloud改造现有服务的工作中,在内部服务的调用方式上选择了Feign组件,由于服务与服务之间有权限控制,发现通过Feign来进行调用时如果发生了401.407错误时 ...
- Eclipse的优化
1. 取消系统的自动折叠 Window->Preferences-> Java->Editor->Folding: Enable folding 2. 取消按".&q ...
- JVM如何理解Java泛型类
//泛型代码 public class Pair<T>{ private T first=null; private T second=null; public Pair(T fir,T ...
- 导出excel 的方法及示例
一.基本知识 1.Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能. 2. HSSF 是Horribl ...