Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-12-2010, 12:12 PM   #1
Gavin Harper
Registered: Feb 2010
Location: Finland
Distribution: Slackware
Posts: 169

Rep: Reputation: 24
BASH: Each line of multiple text files gets added to one line

I currently have 3 files with floating point data that I wish to have in a single file with the format:

F1      F1     F3          Output

a1      b1     c1          a1 b1 c1
a2      b2     c2          a2 b2 c2
a3      b3     c3          a3 b3 c3
a4      b4     c4          a4 b4 c4
I would greatly appreciate any intuition on how to go about this.

Thank you in advance!
Old 09-12-2010, 01:02 PM   #2
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235

    while read -u 3 A && read -u 4 B && read -u 5 C; do
        echo "$A $B $C"
} 3<"$1" 4<"$2" 5<"$3"
save it to then run

bash F1 F2 F3 > OUTPUT
1 members found this post helpful.
Old 09-12-2010, 01:22 PM   #3
Gavin Harper
Registered: Feb 2010
Location: Finland
Distribution: Slackware
Posts: 169

Original Poster
Rep: Reputation: 24
Thank you very very much!

Worked a charm
Old 09-12-2010, 08:31 PM   #4
Senior Member
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
$ paste file1 file2 file3


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
[SOLVED] Using python to merge two text files line for line simplified Programming 1 07-06-2010 02:09 PM
a little bash help: cat multiple files together except first line? sanimfj Linux - General 3 02-09-2010 05:27 PM
bash : read every line from text file starting at given line number quadmore Programming 4 02-20-2009 01:29 PM
Bash: How to add a line on top of text files guest Programming 12 02-07-2009 07:23 AM
Search values within multiple files line to line Chrizzieej Programming 5 09-26-2008 05:11 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:44 AM.

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