使用bash提取文本文件中的特定行

时间:2018-08-17 18:36:31

标签: bash unix

我正在运行以下命令:

grep "folder1/folder2/folder3/.\*/results/.*.vcf.gz"         some_file.txt |grep ".vcf.gz$"  > vcffiles.txt

和我在vcffiles.txt文件中的输出是这样

folder1/folder2/folder3/folder4.1/results/B111.vcf.gz
folder1/folder2/folder3/folder4.2/results/B112.vcf.gz
folder1/folder2/folder3/folder4.1/folder6/folder7/results/B122.vcf.gz
folder1/folder2/folder3/folder4.1/folder6/folder7/folder8/results/B123.vcf.gz

我只想要前两行,而不想要后两行。如何修复此代码以获取所需的信息?

1 个答案:

答案 0 :(得分:0)

您可以使用其他过滤器从结果中删除不需要的行。

... | grep -v "folder[678]"