LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   For foo in bar; do (https://www.linuxquestions.org/questions/programming-9/for-foo-in-bar%3B-do-383753/)

angel115 11-16-2005 02:33 PM

For foo in bar; do
 
I have 3 file
file1
Code:

file1 line1
file1 line2

file2
Code:

file2 line1
file2 line2

file3
Code:

file3 line1
file3 line2

and i want an output like this:
Code:

file1 line1 + file2 line1 = file3 line1
file1 line2 + file2 line2 = file3 line3

I was thinking to use

For in do
and do some thing like this
Code:

#!/bin/bash
for linefile1 in $( cat file1 ); do
  for linefile2 in $( cat file2 ); do
    for linefile3 in $( cat file3 ); do
cat >> my_output_file << EOF
$linefile1 + $linefile2 = $linefile3
EOF

but it doesn't work...:cry: f

homey 11-16-2005 04:52 PM

Do you mean something like this....
Code:

#!/bin/bash
# Example: ./test file1.txt file2.txt

>file3.txt
cat $1 $2 |\
while read a ; do
  echo $1 $a + $2 $a = file3.txt $a >> file3.txt
done



All times are GMT -5. The time now is 11:38 PM.