如何通过Linux处理此问题:
文件一:
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 0, 1" --ver --timeads=10
文件2:
99
1000000
99282828
111
结果:
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 99, 1" --ver --timeads=10
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 1000000, 1" --ver --timeads=10
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 99282828, 1" --ver --timeads=10
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 111, 1" --ver --timeads=10
这意味着我在 file1 中有一个包含命令的文件,我需要从文件 2 复制数字并将命令逐行粘贴到新文件中,并替换后面的数字SIZET
答案1
xargs
+怎么样sed
?
$ xargs -I{} -a File2 sed 's/SIZET 0, 1/SIZET {}, 1/' File1
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 99, 1" --ver --timeads=10
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 1000000, 1" --ver --timeads=10
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 99282828, 1" --ver --timeads=10
1 -b 2 --guide=5 --drop=3 --errors-parse --win-flags="dirwin pc_hard_no,pc_hard_expiry_month,pc_hard_expiry_year,pc_ver with hardvr.type_portals_methods_file WHERE pc_hard_no > 99999999999999 VER pc_hard_expiry_date > '2017-10-31' VER pc_ver > 0 SIZET 111, 1" --ver --timeads=10