找出,a文件中第1列,替换依次成b文件中第8列;

找出,a文件中第1列,替换依次成b文件中第8列;

#!/bin/bash

declare -i i=0        # 定义一个i变量,赋予初始值为 0
declare -i j=0        #定义一个i变量,赋予初始值为 0 

for data in `cat ./0717_auto_renew_success.txt`
do
let i=$i+1

     for aaa in `awk -F "'" '{print $8}' test.txt`
     do
     let j=$j+1
     if [[ $i == $j ]];then    
     sed -i "$j s/$aaa/$data/" test.txt
     fi
     done
j=0

done


[root@standbyha luo]# more 0717_auto_renew_success.txt
11111111111
22222222222

[root@standbyha luo]# more test.txt
insert into COM_BGT_SM_20150723 (  bs_content, bs_time, bs_src_id, bs_receiver_num, bs_service_id ) values  (  '
', 'FREE' );  . . ', '20150723103400', '8585', '11111111111
insert into COM_BGT_SM_20150723 (  bs_content, bs_time, bs_src_id, bs_receiver_num, bs_service_id ) values  (  '


你可能感兴趣的:(shell,sed)