• shell 两个rpm包做差分


    当前目录下两个rpm包做差分。

    *.rpm

    两个目录,解压rpm包。

    export LANG=c

    差分判断是脚本还是Binary Files

    脚本添加命令行提示符,awk。

    [root@sj_x861 diff_rwz]# cat diff_rpm.sh
    #!/bin/bash

    export LANG=c
    source ~/.bashrc

    #############################
    #basic command label
    #############################
    if [ "$(whoami)" = "$(basename $(pwd))" ]; then
         cmd_label="[$(whoami)@$(hostname) ~]# "
    else
         cmd_label="[$(whoami)@$(hostname) $(basename $(pwd))]# "
    fi

    mkdir new_bin/ new_rpm/ old_bin/ old_rpm/
    rpms=(`ls *.rpm`)
    cp -a ${rpms[0]} old_rpm
    cp -a ${rpms[1]} new_rpm

    echo -e "${cmd_label}ls"
    ls
    echo -e "${cmd_label}ls -l */*.rpm"
    ls -l */*.rpm
    echo -e "${cmd_label}md5sum */*.rpm"
    md5sum */*.rpm
    echo -e "${cmd_label}cd new_bin/"
    cd new_bin/
    echo -e "${cmd_label}ls"
    ls
    echo -e "${cmd_label}rpm2cpio ../new_rpm/*.rpm | cpio -idm"
    rpm2cpio ../new_rpm/*.rpm | cpio -idm
    echo -e "${cmd_label}cd ../old_bin/"
    cd ../old_bin/
    echo -e "${cmd_label}ls"
    ls
    echo -e "${cmd_label}rpm2cpio ../old_rpm/*.rpm | cpio -idm"
    rpm2cpio ../old_rpm/*.rpm | cpio -idm
    echo -e "${cmd_label}ls"
    ls
    echo -e "${cmd_label}cd .."
    cd ..
    echo -e "${cmd_label}ls"
    ls
    echo -e "${cmd_label}diff -r old_bin/ new_bin/"
    diff -r old_bin/ new_bin/

    diff -r old_bin/ new_bin/ | grep "Binary files " >/var/tmp/diff_rpm.txt
    if [[ -s /var/tmp/diff_rpm.txt ]];then
            echo -e "${cmd_label}diff -r old_bin/ new_bin/ | grep "Binary files " | awk '{print $3; print $5}' | xargs md5sum"
            diff -r old_bin/ new_bin/ | grep "Binary files " | awk '{print $3; print $5}' | xargs md5sum
    fi

    diff -r old_bin/ new_bin/ | grep "diff -r "  >/var/tmp/diff_rpm.txt
    if [[ -s /var/tmp/diff_rpm.txt ]];then
            echo -e "${cmd_label}diff -r old_bin/ new_bin/ | grep "diff -r " | awk '{print $3; print $4}' | xargs md5sum"
            diff -r old_bin/ new_bin/ | grep "diff -r " | awk '{print $3; print $4}' | xargs md5sum
    fi

    rm -rf new_bin/ new_rpm/ old_bin/ old_rpm/
    [root@sj_x861 diff_rwz]# cat

    awk

    [root@sj_x861 diff_rms]# cat temp
    ls
    ll */*.rpm
    md5sum */*.rpm
    cd new_bin/
    ls
    rpm2cpio ../new_rpm/*.rpm | cpio -idm
    cd ../old_bin/
    ls
    rpm2cpio ../old_rpm/*.rpm | cpio -idm
    ls
    cd ..
    ls
    diff -r old_bin/ new_bin/
    diff -r old_bin/ new_bin/ | grep "Binary files " | awk '{print $3; print $5}' | xargs md5sum  =>双引号和美元符号需要转义.
    #diff -r old_bin/ new_bin/ | grep "diff -r " | awk '{print $3; print $4}' | xargs md5sum
    [root@sj_x861 diff_rms]# cat temp | awk '{ print "echo -e "${cmd_label}"$0"""; print $0}'
    echo -e "${cmd_label}ls"
    ls
    echo -e "${cmd_label}ll */*.rpm"
    ll */*.rpm
    echo -e "${cmd_label}md5sum */*.rpm"
    md5sum */*.rpm
    echo -e "${cmd_label}cd new_bin/"
    cd new_bin/
    echo -e "${cmd_label}ls"
    ls
    echo -e "${cmd_label}rpm2cpio ../new_rpm/*.rpm | cpio -idm"
    rpm2cpio ../new_rpm/*.rpm | cpio -idm
    echo -e "${cmd_label}cd ../old_bin/"
    cd ../old_bin/
    echo -e "${cmd_label}ls"
    ls
    echo -e "${cmd_label}rpm2cpio ../old_rpm/*.rpm | cpio -idm"
    rpm2cpio ../old_rpm/*.rpm | cpio -idm

    image

    end

  • 相关阅读:
    python学习笔记(33)pycharm中使用git
    VUE基础3-过滤器与生命周期
    VUE基础2-双向数据绑定
    VUE基础1方法与指令
    HTML基础之JS
    HTML基础之DOM操作
    HTML基础之CSS
    HTML基础之HTML标签
    python学习笔记(32)多线程&多进程
    python学习笔记(30)深拷贝、浅拷贝
  • 原文地址:https://www.cnblogs.com/laorenjia/p/4740644.html
Copyright © 2020-2023  润新知