签到成功

知道了

CNDBA社区CNDBA社区

shell循环读取前一天的db2pd文件

2022-03-07 15:22 994 0 原创 Linux
作者: hbhe0316
#!/usr/bin/ksh
###############################################################################################################
# Script name: get_table.sh
# Script description: Get "db2pd -d <dbname> -tab" information
# Current Release Version: 1.0.0
# Script Owner: He ,Haibo
# Latest editor: He, Haibo
# Support platform:  Linux OS for Linux.
# Change log: None
# Description:Date 2022/3/7
#
#
###############################################################################################################
file_path="/tmp"
file_start="TCB Table Stats:"
file_end="TCB Index Information:"



get_db2pd_information(){
    for file in `ls $file_path/aaa_db2pd_tcbstats_$(date -d 'yesterday' +%Y%m%d)*.out | xargs`
    do
            file_start_num=`cat ${file} | grep -n "${file_start}" | cut -d ":" -f 1`
            file_end_num=`cat ${file} | grep -n "${file_end}" | cut -d ":" -f 1`
#            echo "file-start_num is ${file_start_num}"
#            echo "file_end_num is ${file_end_num}"
            file_start_num=$(($file_start_num-1))
            file_end_num=$(($file_end_num-1))
#            echo "file is ${file}"
#            echo "file-start_num is ${file_start_num}"
#            echo "file_end_num is ${file_end_num}"

            file_result="${file}.res"
#            echo "file_result is ${file_result}"
            for ((i=$file_start_num; i<=$file_end_num; i++))
            do
                sed -n "$i"p"" ${file} | awk -F ' ' {'print $3,$2,$4,$11,$12,$13'} >> ${file_result}
            done
    done 
}

main(){
    get_db2pd_information
}

main
http://www.cndba.cn/hbhe0316/article/107861
http://www.cndba.cn/hbhe0316/article/107861
http://www.cndba.cn/hbhe0316/article/107861
http://www.cndba.cn/hbhe0316/article/107861
http://www.cndba.cn/hbhe0316/article/107861
http://www.cndba.cn/hbhe0316/article/107861
http://www.cndba.cn/hbhe0316/article/107861
http://www.cndba.cn/hbhe0316/article/107861 http://www.cndba.cn/hbhe0316/article/107861 http://www.cndba.cn/hbhe0316/article/107861

版权声明:本文为博主原创文章,未经博主允许不得转载。

Linux

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1146182次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ