查找文本文件中与行匹配的文件名

我有一个文本文件,如下所示:

orthogroup1
orthogroup4
...

我有一个包含文本文件的目录,如下所示:

orthogroup1.faa.reconciled
orthogroup2.faa.reconciled
orthogroup3.faa.reconciled
orthogroup4.faa.reconciled
...

我想使用文本文件来获取目录中的相应文件名。

结果应该类似于:

orthogroup1.faa.reconciled
orthogroup4.faa.reconciled

我该怎么做?

先谢谢您了:)

liuqingshuai_110 回答:查找文本文件中与行匹配的文件名

-f的{​​{1}}选项允许您从文件中提取图案。在grep的输出中使用它来过滤列表:

find
,

您能否定义“在我的目录中获取文件名”是什么意思?您对他们有什么下一步的打算?

似乎您可能想使用results = Geocoder.search("",postal_code: 'V9M 3N3') results = Geocoder.search('K1G 9L1',components: [:postal_code]) 之类的东西,尽管后者可能是过分的。有关更多信息,请参见What is the difference between sed and awk?

,

类似这样的东西:

suffix='.faa.reconciled'
for line in $(cat file.txt); do
    echo $line$suffix
done

示例:

$ cat file.txt
orthogroup1
orthogroup4

$ ls -l ortho*
orthogroup4.faa.reconciled
orthogroup3.faa.reconciled
orthogroup2.faa.reconciled
orthogroup1.faa.reconciled

$ suffix='.faa.reconciled'; for line in $(cat file.txt); do echo $line$suffix; done
orthogroup1.faa.reconciled
orthogroup4.faa.reconciled
本文链接:https://www.f2er.com/3151693.html

大家都在问