[英]find common string in two text files using batch script
我正在尝试在两个文本文件中找到通用字符串。 例如,第一个文本文件包含以下1.txt
//documents #5
##text
//documents/A #6
//documents/B #7
第二个文本文件包含以下内容: 2.txt
//documents/A #3
output.txt的
//documents/A #6
如果找到公用字符串,则预期输出从1.txt文件获取的最后一个数字。 try.cmd
@echo off
awk "NR==FNR {a[$0]=1;next} !a[$0]" 1.txt 2.txt > output.txt
for /F "usebackq tokens=1" %%A in ("output.txt") do (
echo %%A
不确定要求,但是,也许
awk "{print $1}" 2.txt | findstr /g:/ /l /b 1.txt
没有awk
cmd /q /c"(for /f "usebackq" %%a in ("2.txt") do echo(%%a)" | findstr /g:/ /l /b 1.txt
只有awk
awk "{a[$1]=!a[$1]} !a[$1]" 2.txt 1.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.