2016-10-06 112 views
1

我正在使用OS X El Capitan V10.11.3。如何在Bash中創建一個循環來搜索一組.gz文件

我能夠獲得與測試文件一起使用的語法,但在一組.gz文件中使用它卻很困難。

他的工作是測試文件:

#!/bin/bash 
while read p; do 
    grep $p test2.txt>> final.txt 
done <test3.txt 

我試圖寫一個循環來搜索在「test3.txt」文件中使用的SNP清單超過30 .gz文件解

#!/bin/bash 
while read p; do 
grep $p zcat chunk?-chr*.imputed.info.gz >> Final.txt 
done <test3.txt 

的test3.txt文件具有在.gz文件解代表1個SNP。當我運行上面的語法會創建一個文件proxy_imputed.txt,但不拉SNP。

有什麼想法?

+0

請看看[editing-help](http://stackoverflow.com/editing-help)。 – Cyrus

回答

0

我是在同一平臺上,但不能讓你的語法的工作 - 這似乎達到預期的效果(稱之爲findString.sh):

#!/bin/bash 

while read p ; do 
    gzcat *.gz | grep $p >> Final.txt; 
done 

當一個像運行

./findString.sh < test3.txt 

不知道我是否在正確的軌道上,但似乎工作。注意我必須使用gzcat來讀取gzip文件,zcat正在尋找* .Z

相關問題