How can I run for loop with two variables
or in other words is it acceptable to do that? I will clarify my question by the following example:
I have a list of letters included in a text file "names.txt" and I have numbers included in text file "numbers.txt" each number in "numbers.txt" is equal to letter in "names.txt" (row by row) I want to create folders has the names in names.txt + the numbers in numbers.txt
names.txt numbers.txt output_folder name
A 1 A1
B 2 B2
C 3 C3
D 4 D4
E 5 E5
to create folders has the names included in names.text I can use the following code:
#!/bin/bash
in=/in/on/an
out=/ss/tt/nn
for i in $(cat $in/names.txt); do
mkdir ${in}/${i}
done
How can I add a second variable to a for loop i.e in the previous code we have the variable i is belonging to the names.txt how can I add variable b belonging to numbers.txt?
while
loop instead. – terdon Nov 11 '14 at 02:46${#let[@]}
is). It is just a way to iterate over the elements in an array. – terdon Nov 11 '14 at 02:51