I have a bash script that I need to run for a series of files. The script takes 4 arguments. The first ref
is a file, fun
is a directory, R1arr
and R2arr
each are arrays containing a series of files with specific features in a given directory.
My script.sh
is as follows:
ref="$1"
fun=$2
R1arr="$@"
R2arr="$@"
analyseReads -i "$ref" -o "$fun" --left "${R1arr[@]}" --right "${R2arr[@]}"
And I run it for various files as follows:
FORWARD=($(for i in Sample_STE*/*R1; do echo $i; done))
REVERSE=($(for i in Sample_STE*/*R2; do echo $i; done))
bash script.sh "$ref" "$fun" "${FORWARD[@]}" "${REVERSE[@]}"
I get an error since "${FORWARD[@]}"
and "${REVERSE[@]}"
does not only contain the files in the array FORWARD
and REVERSE
but it also contains "$ref"
and "$fun"
. Why does this happen and how could I solve this issue?