I have a file hierarchy resembling this:
a0/files/x.txt
a1/files/y.txt
a2/files/z.txt
and I need to make these two arrays:
labels=("a0" "a1" "a2")
paths=("a0/files/x.txt" "a1/files/y.txt" "a2/files/z.txt")
This is what I did:
labels="a*"
paths=(); for d in $labels; do f=$(find $d -name "*.txt"); paths+="${f}"; done
labels
is fine, but paths
comes out as all the paths concatenated into a string, i.e. a0/files/x.txta1/files/y.txta2/files/z.txt
rather than an array of paths. What am I doing wrong? bash v. 4.1.2.