Hello all,
I was wondering if I could get some help with a script that I have been struggling with. I am trying to iterate over two directories with a for loop, but I also need to use the names of the files from one of my directories to name the new files. I can't get the variable name[$i] to work. Each directory has the same amount of files, which is 20 files. So, when I "echo ${name[$i]}" is should get 20 strings outputted, but I get 1.
Here is my code:
cd /Users/personal/Desktop/blackberry_hybseq_data/Data_and_Nov2018_NZ_assembly/blackberry_hybseq/Align/Hillquist/
array=ls -1 /Users/personal/Desktop/blackberry_hybseq_data/Data_and_Nov2018_NZ_assembly/blackberry_hybseq/*gz
array_2=ls -1 /Users/personal/Desktop/blackberry_hybseq_data/Data_and_Nov2018_NZ_assembly/blackberry_hybseq/Align/Hillquist/*.bam
for ((i=0; i<${#array[@]}; ++i)); do
name[$i]=echo ${array[$i]} | cut -d "/" -f8 | cut -d "." -f1
;
echo ${name[$i]};
done exit
Here is my output:
R01_ccs.UV3pbc017__UV3pbc017
Any help on how to get my code to fully iterate over all 20 entries and not just the first one, would be greatly appreciated.