我正在尝试查找文件夹中所有* .txt文件中的模式,这些文件是行中数字列表。我想在包含* .vcf格式的一堆东西的文件中找到包含这些数字的行。不同的列表必须生成不同的输出文件,这些文件应该类似于file.output。 我试过这个但是没有用(抱歉,我很新手)也许我可以使用awk或其他更奇特的东西?
for file in ./*.txt
do
cat $file|while read LINE
do
grep "$LINE" ./AC-AN-table.v2.vcf > "$file.output"
done
答案 0 :(得分:0)
我会这样做:
ls *.txt | perl -nle 'system("grep -f $_ ./AC-AN-table.v2.vcf > $_.output");
解释: perl -nle循环输入,并在每个循环中执行指定的perl表达式。更多信息请见perlrun,但简而言之:
-n : loop over input without autoprinting
-l : modify line endings
-e : expression to execute
grep的-f
选项提供一个文件,其中包含要搜索的模式列表。每行1个模式。