zoukankan      html  css  js  c++  java
  • extract specified contents from two files.

    src_dir=$(pwd)/All_h
    dst_dir=$(pwd)/All
    diff_dir=$(pwd)/diff
    
    if [ ! -d $diff_dir ]
    then
    	mkdir $diff_dir
    fi
    
    for src_full_entry in $src_dir/*
    do
    	src_cat_entry=$(echo $src_full_entry | sed -e "s/.[0-9a-rA-F]{8}$//")
    	src_cat_entry=$(basename "$src_cat_entry")
    	src_ivr_log="$src_full_entry/de_ivr.log"
    	if [ -f "$src_ivr_log" ]
    	then
    		#echo "$src_cat_entry"
    		dst_ivr_log=$(find $dst_dir -regextype posix-egrep -regex ".*/$src_cat_entry.[0-9A-Fa-f]{8}/ivr.log$")
    		#echo $dst_ivr_log
    		if [ -f "$dst_ivr_log" ]
    		then
    			diff_ivr_log="$diff_dir/$src_cat_entry.diff"	
    			summary="$diff_dir/$src_cat_entry""_summary.txt"
    			#echo $diff_ivr_log
    			#diff -u "$src_ivr_log" "$dst_ivr_log" > "$diff_ivr_log"
    		
    			echo "" > "$summary"			
    
    			echo "##########################################################" >> "$summary"
    			echo "$src_ivr_log:" >> "$summary"
    			echo "##########################################################" >> "$summary"
    			grep -i -n -A 20 "$src_cat_entry" "$src_ivr_log" >> "$summary"
    
    			echo "" >> "$summary"
    			echo "##########################################################" >> "$summary"
    			echo "" >> "$summary"
    
    			echo "##########################################################" >> "$summary"
    			echo "$dst_ivr_log:" >> "$summary"
    			echo "##########################################################" >> "$summary"
    			grep -i -n -A 20 "$src_cat_entry" "$dst_ivr_log" >> "$summary"
    			#diff -u "$src_ivr_log" "$dst_ivr_log" 
    		fi
    	fi
    done
    

      

    if we want to use regular expressions for find command, we can do it like this.

    find $dst_dir -regextype posix-egrep -regex ".*/$src_cat_entry.[0-9A-Fa-f]{8}/ivr.log$"
    

      

  • 相关阅读:
    MySQL Execution Plan--合理利用隐式的业务逻辑
    MySQL Table--MySQL外键
    MySQL倒序索引测试2
    MySQL倒序索引测试1
    CCNA-3.硬件介质
    CCNA-2.OSI 7层网络模型
    CCNA-1.认识网络
    windows本地安装Oracle数据库
    扫码登录实现原理
    phpunit 单元测试
  • 原文地址:https://www.cnblogs.com/long123king/p/3812225.html
Copyright © 2011-2022 走看看