Results 1 to 2 of 2
I've been learning bash scripting, and trying some basic stuffs. Just came across a situ where I have to execute a command, where attributes should be from each line of ...
- 12-06-2010 #1
using two variables i and j together in 'for' - bash
I've been learning bash scripting, and trying some basic stuffs. Just came across a situ where I have to execute a command, where attributes should be from each line of 2 files. file1 and file2.
I guess it can be done with for and while loops. Is there a way to use multiple variables in a single line like this (&& is not working here)
for i in `cat file1` && j in `cat fil2` ; do command $i $j ; done
I am trying to pick i and j simultaneously and execute a command using their values. Curious about how two variables can be used with a single for loop. Any help will be appreciated. Thanks!
- 12-11-2010 #2
Is this what you want?
Code:exec 3< "$file1" exec 4< "$file2" while read a <&3; read b <&4 do ## do something here with $a and $b, e.g.: printf "%-20s %s\n" "$a" "$b" done


Reply With Quote