bash脚本-for循环

假设我有一个 txt 文件,例如:

CGND_01234    CGND-HRA-00736
CGND_34563    CGND-HRA-00567
...

如何在 bash 中为下面的行创建一个 for 循环来迭代文件中的每一行?

find ./${first_word_in_the_first_line} -name "${second_word_in_the_first_line}*.bam" -type f 
find ./${first_word_in_the_second_line} -name "${second_word_in_the_second_line}*.bam" -type f
...

回答

while read环是一种常见的方式读取文件中的行由行。方便的是,如果您将多个变量名称传递给read它,它也会同时拆分该行。

while read -r dir file; do
    find "$dir" -name "$file*.bam" -type f 
done < file.txt


以上是bash脚本-for循环的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>