I try to wrote a program using awk (in Windows env) that reads an inp.txt file and for each record searches for corrispondent line present in file history.txt starting in history.txt from position 21 by 55 characters. If found, print the full matched history.txt line
inp.txt
AAA_BBB_CCC_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
AAA_BBB_DDD_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
history.txt
2023-01-01 12.00.00 AAA_BBB_EEE_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
2023-01-01 12.00.00 AAA_BBB_CCC_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
2023-01-01 12.00.00 AAA_FFF_CCC_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
I wtote this simple script
gawk "NR==FNR {history_lines[substr($0,21,55)]=0; next} {search_string=($1)} search_string in history_lines" history.txt inp.txt
gawk "NR==FNR {search[substr($0,21,35)]; next} {for (s in search) if(index($0, s)) {print; break}}" inp.txt history.txt
gawk "NR==FNR {search[substr($0,21,35)]; next} {for (s in search) if(index($0, s)) {print; delete search; break}}" inp.txt history.txt
If there's some error please tell me
My question is how can I pass a single row as parameter?
Thank you in advance
inp.txt
AAA_BBB_CCC_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
AAA_BBB_DDD_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
history.txt
2023-01-01 12.00.00 AAA_BBB_EEE_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
2023-01-01 12.00.00 AAA_BBB_CCC_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
2023-01-01 12.00.00 AAA_FFF_CCC_77_1c2a39c6-199e-4f4f-9971-32d3f7fdb74f.zip
I wtote this simple script
gawk "NR==FNR {history_lines[substr($0,21,55)]=0; next} {search_string=($1)} search_string in history_lines" history.txt inp.txt
gawk "NR==FNR {search[substr($0,21,35)]; next} {for (s in search) if(index($0, s)) {print; break}}" inp.txt history.txt
gawk "NR==FNR {search[substr($0,21,35)]; next} {for (s in search) if(index($0, s)) {print; delete search
If there's some error please tell me
My question is how can I pass a single row as parameter?
Thank you in advance