** Merging Two Text Files Parallel **

** Merging Two Text Files Parallel **

Post by John Beac » Mon, 02 May 1994 02:58:18



   Suppose you have the following two ascii files.

   $ cat test1
   12345
   12345
   12345
   12345
   $ cat test2
   67890
   67890
   67890
   $ _

   How do you merge those two files as one, say test3,
   which looks like you-already-guessed-what?

   $cat test3
   12345        67890
   12345        67890
   12345        67890
   12345
   $ _

########################################################################

% paste test1 test2

see man paste
--
________________________________________________________________________

Dept. Physics - Chamberlin Hall, Univ. of Wisconsin, Madison, WI, 53706
________________________________________________________________________

 
 
 

** Merging Two Text Files Parallel **

Post by P.A.D.Rhod.. » Mon, 02 May 1994 02:38:52



>How do you merge those two files as one, say test3,

>$cat test3
>12345       67890
>12345

Hi, I have exactly this problem too.
The best solution I could come up with was to do
(assuming file1 is 12345, file2 is 67890) is
cat blank5 >> file1    (where blank5 is "     ") for instance)
cat file2  >> file1
tr -d "[:cntrl:]" <file1 >! newfile  (this deletes control chars including
                                                newline )
then cat blank1 >> newfile (where blank1 is " ") this is just to put a
                        newline character at the end of the joined lines).

This is FAR FROM SATISFACTORY so if someone has a better solution, please
send it on. There are more comples utilities to do all sorts of things
but as I am a none expert you'll have to make do with my feeble attempt for
the time being.

Hope this helps.

Pete.

--
 Pete Rhodes         |                                     |      Email

 Guildford           |                                     | student.lut.ac.uk
 Surrey GU6 2SE      |                                     |