最近做一个数据清理,根据行号清理,所以需要查出这个行的最大最小值出来进行删除,如果靠手动每次去查,太麻烦所以就用在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值的更多相关文章

  1. [转]Shell脚本中获取SELECT结果值的方法

    http://blog.itpub.net/13885898/viewspace-1670297/ 有时候我们可能会需要在Shell脚本中执行SELECT语句,并将结果赋值给一个变量,对于这样的情形, ...

  2. shell脚本中获取当前所在目录地址

    shell脚本中获取当前所在目录如下 #!/bin/bash work_path=$() cd ${work_path} work_path=$(pwd) cd ${work_path}/src

  3. linux,shell脚本中获取脚本的名字,使用脚本的名字。

    需求描述: 写shell脚本的过程中,有时会需要获取脚本的名字,比如,有的时候,脚本 中会有usage()这种函数,可能就会用到脚本的名字. 实现方法: shell脚本中,通过使用$0就可以获取到脚本 ...

  4. Linux Shell脚本中获取本机ip地址方法

    ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"​ 命令解释 ...

  5. 如何在shell脚本中获取当前用户名?

    答:使用环境变量USER即可 如在脚本中打印当前用户名; #!/bin/sh echo "user name = ${USER}"

  6. shell脚本中case select 的使用

    #!/bin/bash # case echo "1.Install PHP" echo "2.Install Mysql" echo "3.Inst ...

  7. shell脚本中获取本机ip地址的方法

    ipaddr='172.0.0.1' ipaddr=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/ ...

  8. 在Shell脚本中获取指定进程的PID

    注意这条命令用反引号(Tab上面的那个键)括起来,作用类似于${ } processId = ` ps -ef | grep fms.jar | grep -v grep | awk '{print ...

  9. shell脚本中select循环语句用法

    shell脚本中select循环语句 1. 脚本中select的语法格式 select VAR in LIST do command1 command2 ... ... commandN done s ...

随机推荐

  1. Mahout系列之-----相似度

    Mahout推荐系统中有许多相似度实现,这些组件实现了计算不能User之间或Item之间的相似度.对于数据量以及数据类型不同的数据源,需要不同的相似度计算方法来提高推荐性能,在mahout提供了大量用 ...

  2. 【一天一道LeetCode】#27. Remove Element

    一天一道LeetCode系列 (一)题目 Given an array and a value, remove all instances of that value in place and ret ...

  3. 【一天一道LeetCode】#16. 3Sum Closest

    一天一道LeetCode系列 (一)题目: Given an array S of n integers, find three integers in S such that the sum is ...

  4. 【freeradius3】安装和拓展需求

    这次主要来看看 freeradius的安装,以及Python拓展的例子,还有计费字段根据厂家进行拓展. 3.0版本的安装 参考文章 yum install libtalloc-devel wget - ...

  5. hadoop的节点间的通信

    一个DataNode上的Block是唯一的,多个DataNode可能有相同的Block. 2)通信场景: (1)NameNode的映射表上不永久保存每个DataNode所对应的block信息,而是通过 ...

  6. 图像分割之(四)OpenCV的GrabCut函数使用和源码解读

    图像分割之(四)OpenCV的GrabCut函数使用和源码解读         分类:            图像处理            计算机视觉             2013-01-23 ...

  7. leetcode之旅(11)-Integer to Roman

    题目描述: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range fr ...

  8. leetcode之旅(7)-Move Zeroes

    Move Zeroes 题目描述: Given an array nums, write a function to move all 0's to the end of it while maint ...

  9. Python__flask初识

    1.  debug:在app.run()里面加上app.run(debug=True), 在浏览器中调试的时候可以直接显示出错误. 2.  在url中传递参数,可以这样 @app.route('/ch ...

  10. Jquery getJSON方法分析

    准备工作 ·Customer类 public class Customer {     public int Unid { get; set; }     public string Customer ...