Bash Loop Help (want to echo aa, bb, cc) -


loop logic confuses me, simple solution. current loop:

for in b; j in b; echo $i$j; done; done 

this loop prints following output:

 aa  ab  ba  bb 

i print:

 aa  bb 

i want match first 2 letters, second 2 letters , on. want expand on files in 2 different directories. want print first file name in dir1, first in dir2. 2nd in dir1 , 2nd in dir2. trying simplify , understand logic first.

i suggest using arrays solve problem:

dir1_files=( dir1/* ) dir2_files=( dir2/* )  (( = 0; < ${#dir1_files[@]}; ++i ));     echo "${dir1_files[i]} ${dir2_files[i]}"  done 

this assumes number of files in each directory same.


Comments