Results 1 to 5 of 5

Thread: Concatenation of several large files

  1. #1
    Join Date
    Jan 2010
    Posts
    317

    Concatenation of several large files

    I am under Cygwin. I saw lots of different ways to proceed with the operation of concatenation of files on the net. I wonder which is the fastest and least likely to be hampered by large file sizes of input and output.
    Code:
    open(OUT, ">> $output") or die("Can't create output file: $!");
    binmode(OUT);
    foreach (@files) {
          open(IN, "< $_")
          or die("Can't open input file $_: $!");
          binmode(IN);
          {
               local $_;
               print OUT $_ while <IN>;
          }
    }

  2. #2
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Concatenation of several large files

    This method is good. Small corrections
    Code:
    open(OUT, '>' $output) or die("Can't create output file: $!");
    binmode OUT;
    foreach (@files) {
          open(IN, '<', $_) or die("Can't open input file $_: $!");
          binmode IN;
          print OUT $_ while (<IN>);
          close(IN);
    }
    close(OUT);

  3. #3
    Join Date
    Jan 2010
    Posts
    317

    Re: Concatenation of several large files

    Thank you for your help and it worked! One more thing, which is faster methods: using the shell as a "cat" or "copy"?

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Concatenation of several large files

    copy => Makes a copy, and so do not allow the concatenation. This is not its goal.
    cat => Displays on the screen, but then it loses in performance and its goal is not concatenation.

  5. #5
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Concatenation of several large files

    cat - Concatenate files and displays them on standard output.

    Syntax
    Code:
    cat [-benstuvAET] [--number] [--number-nonblank] [--squeeze-blank] [--show-nonprinting] [--show-ends] [--show-tabs] [--show-all] [--help] [--version] [file...]
    Description

    cat displays the standard output content of each file (or the contents of the coming standard if no filename is provided, or if the name `- 'is specified).

    Parameters

    -b, --number-nonblank
    Nonblank number output, starting with 1.
    -e
    Equivalent to -vE.
    -n, --number
    Sorted output, starting with 1.
    -s, --squeeze-blank
    Replace multiple blank lines with a single blank line.
    -t
    Equivalent to -vT.
    -u
    No effect - for Unix compatibility only.
    -v, --show-nonprinting
    Show control characters, Show romanization
    `^', and prefixed with `M-' the characters with the eighth bit set.
    -A, --show-all
    Equivalent to -vET.
    -E, --show-ends
    Show a `$' at the end of each line.
    -T, --show-tabs
    Displays the TAB character so: `^I'.
    --help
    Display a help message on standard output and exit normally.
    --version
    Show version number to stdout and exit normally.

Similar Threads

  1. Replies: 1
    Last Post: 05-06-2012, 12:20 PM
  2. How to split large files in Mac OS X
    By strongArm in forum Operating Systems
    Replies: 5
    Last Post: 31-07-2011, 10:04 AM
  3. How do I get large media files onto my ps3 from my pc
    By RoyALongfield in forum Video Games
    Replies: 2
    Last Post: 05-02-2011, 02:57 AM
  4. Can't download large files
    By NewComer in forum Technology & Internet
    Replies: 6
    Last Post: 28-04-2010, 01:05 PM
  5. How to split large flv files ?
    By FELIPA in forum Windows Software
    Replies: 3
    Last Post: 19-06-2009, 04:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,511,175.95592 seconds with 17 queries