给定一个包含2列,字符串和文件名的文件,如何用grep命令循环?还想将输出指向与不同文件夹中的SEQFILE相同的名称。相信以下是接近的,正确的引用缺失:
while IFS=" ", read SEQID SEQFILE
do
grep -A1 -m 1 ${SEQID} ${SEQFILE} > ./tmp/${SEQFILE}
done < missingSeq.txt
答案 0 :(得分:2)
如果文件以逗号分隔,那么IFS=" ",
没有意义,但如果它的空格分隔,则逗号会阻碍。这可能会解决您在上面提出的问题:
while IFS=' ' read id file; do
grep -A1 -m1 "$id" "$file" > "./tmp/$file"
done < missingSeq.txt
答案 1 :(得分:0)
IFS=' '
while read seq_id seq_file; do
grep -A1 -m1 "$seq_id" "$seq_file" >> ./tep/seq_file # i assume "tep" was actually meant
done < missingSeq.txt