Issue
I have the below command which I want to run through a bash for loop:
inputdir="/mnt/c/Users/OneDrive - ABC/DNA/raw_vcf"
vcfs="(${inputdir}/*.vcf.gz)"
for v in "${vcfs[@]}"
do
echo "input: $v"
done
I got
input: /mnt/c/Users/OneDrive - ABC/DNA/raw_vcf/*.vcf.gz
I think it might be due to the spaces in the path. How to fix this problem?
Solution
Quote only the expansion containing the space, and not the glob (and certainly not the parenthesis).
vcfs=( "$inputdir"/*.vcf.gz )
Answered By - Charles Duffy