On Jan 30, Catherine L Harris said:

>One of the most common needs in data analysis is to "abut" two files.  This
>means to create a single file by horizontally pasting two files together.

If you have Perl, the following program does the job:

  #!/usr/bin/perl -w

  die "usage: $0 file1 file2 > output\n" unless @ARGV == 2;

  open LEFT, $ARGV[0] or die "can't read $ARGV[0]: $!";
  open RIGHT, $ARGV[1] or die "can't read $ARGV[1]: $!";

  while (<LEFT>) {
    chomp;
    print $_, scalar <RIGHT>;
  }

  close LEFT;
  close RIGHT;

This of course assumes that the files are the same number of lines.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to