LinuxQuestions.org
Register a domain and help support LQ
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: 492

Rep: Reputation: 75
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: 56
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 16 07-27-2008 10:22 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


All times are GMT -5. The time now is 06:18 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration