如何使用 Bash 脚本循环遍历两个文件

upe*_*dra 5 bash loops

我有一个file_in.txt包含以下名称的文件 ( ):

aphid_splitseq.1.fasta.annot.xml
aphid_splitseq.2.fasta.annot.xml
aphid_splitseq.3.fasta.annot.xml
aphid_splitseq.4.fasta.annot.xml
aphid_splitseq.5.fasta.annot.xml
Run Code Online (Sandbox Code Playgroud)

我还有另一个文件 ( file_out.txt) 具有以下名称:

aphid_splitseq_1
aphid_splitseq_2
aphid_splitseq_3
aphid_splitseq_4
aphid_splitseq_5
Run Code Online (Sandbox Code Playgroud)

现在我想要这样的陈述

java -cp *:ext/*: es.blast2go.prog.B2GAnnotPipe -in aphid_splitseq.1.fasta.annot.xml -out results/aphid_splitseq_1 -prop b2gPipe.properties -v -annot -dat 
Run Code Online (Sandbox Code Playgroud)

基本上,我要循环通过每个的file_in.txtfile_out.txt并取代的值-in-outij分别。

我在 Bash 中尝试过,但它似乎不起作用:

aphid_splitseq.1.fasta.annot.xml
aphid_splitseq.2.fasta.annot.xml
aphid_splitseq.3.fasta.annot.xml
aphid_splitseq.4.fasta.annot.xml
aphid_splitseq.5.fasta.annot.xml
Run Code Online (Sandbox Code Playgroud)

per*_*eal 7

paste 可能会有所帮助:

#!/bin/bash

paste file_in.txt file_out.txt | while read if of; do
  echo "-in $if -out $of"
done
Run Code Online (Sandbox Code Playgroud)

产量:

-in aphid_splitseq.1.fasta.annot.xml -out aphid_splitseq_1
-in aphid_splitseq.2.fasta.annot.xml -out aphid_splitseq_2
-in aphid_splitseq.3.fasta.annot.xml -out aphid_splitseq_3
-in aphid_splitseq.4.fasta.annot.xml -out aphid_splitseq_4
-in aphid_splitseq.5.fasta.annot.xml -out aphid_splitseq_5
Run Code Online (Sandbox Code Playgroud)

您可以修改它以获得所需的行为。