I' am trying to make a simple bash script that run multiple times a program with several files at once, thought in make this with a for loop. that's why I thought in use a seq with the file names, I could set manually but I think is more fun learn how to do this in a more elegant way. Can someone help me? that's what Iam trying
folder=/user/folder/files_1.fi
folder2=/user/folder/files_2.fi
mypath=/path/to/files/
seq1= folder{??}
seq2= folder2{??}
for x,y in seq1 seq2
output= ${x:0:5}
do
program options -1 $mypath/$seq1 -2 $mypath/$seq2 -o $output
done
I could figure out a way to solve my own problem, and I'am posting here for other looking for the same or similar problem.
Thank you anyway.
$ cat script.sh
#!/bin/bash
seq1=(/path/to/files/*._1.fq)
seq2=(/path/to/files/*._2.fq)
for ((i=0;i<=${#seq1[@]};i++)); do
output=$(echo ${seq1[$i]} | awk '{print substr ($0, 28, 8)}')
program options -1 ${seq1[$i]} -2 ${seq2[$i]} -o $output
done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.