LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-16-2005, 02:33 PM   #1
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Rep: Reputation: 79
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... f
 
Old 11-16-2005, 04:52 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is foo bar satimis Programming 25 04-26-2019 08:21 PM
python mkdir ~/.foo datadriven Programming 1 01-31-2005 11:51 PM
newbie question--What is foo ? indian Linux - General 1 09-24-2004 03:16 AM
grep -r foo /* alles32 Linux - General 2 09-19-2004 06:20 PM
Foo? MasterC Linux - General 2 05-27-2003 03:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration