![](/img/trans.png)
[英]how to loop through 3 files , search for a specific string and match it to a string in another file using bash
[英]bash - How to match files names to use in loop
我想在每对文件上运行循环命令
a_xxx.wig
b_xxx.wig
c_xxx.wig
a_xxx.bed
b_xxx.bed
c_xxx.bed
我想根据样本名称(a,b或c)来匹配文件,并让循环在每个对中运行一个命令,而不必一次执行一个
for file in * do
bedtools intersect -a $sample.wig -b $sample > $sample.bed
done
任何想法或指针将不胜感激
wig
文件是输入,因此只需遍历这些文件即可。 您可以提取文件名的一部分,以用作其他名称的“基础”。
for file in *.wig; do
sample=${file%.wig}
bedtools intersect -a "$sample.wig" -b "$sample" > "$sample.bed"
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.