newbie; appending multiple files

Discussion in 'Perl Misc' started by Steve, May 6, 2004.

  1. Steve

    Steve Guest

    Hello,

    I have files 1.txt, 2.txt, 3.txt.......n.txt. Each file contains a
    single line of text. I need each line of text from all these source
    files to be appended into a single destination file called bulk.txt.

    I have found some marginally helpful stuff in the manpages and faqs
    but not quite what I need. Any pointers are appreciated.

    Thanks,
    Steve
     
    Steve, May 6, 2004
    #1
    1. Advertising

  2. (Steve) wrote in news:eb6d00cc.0405061257.5b167226
    @posting.google.com:

    > Hello,
    >
    > I have files 1.txt, 2.txt, 3.txt.......n.txt. Each file contains a
    > single line of text. I need each line of text from all these source
    > files to be appended into a single destination file called bulk.txt.
    >
    > I have found some marginally helpful stuff in the manpages and faqs
    > but not quite what I need. Any pointers are appreciated.


    And your Perl question is ...?

    cat ?.txt > bulk.txt

    ought to do it.

    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, May 6, 2004
    #2
    1. Advertising

  3. "A. Sinan Unur" wrote:
    >
    > (Steve) wrote in news:eb6d00cc.0405061257.5b167226
    > @posting.google.com:
    > >
    > > I have files 1.txt, 2.txt, 3.txt.......n.txt. Each file contains a
    > > single line of text. I need each line of text from all these source
    > > files to be appended into a single destination file called bulk.txt.

    >
    > And your Perl question is ...?
    >
    > cat ?.txt > bulk.txt
    >
    > ought to do it.


    The OP said append so that should be:

    cat ?.txt >> bulk.txt


    John
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, May 7, 2004
    #3
  4. Steve

    Anno Siegel Guest

    A. Sinan Unur <> wrote in comp.lang.perl.misc:
    > (Steve) wrote in news:eb6d00cc.0405061257.5b167226
    > @posting.google.com:
    >
    > > Hello,
    > >
    > > I have files 1.txt, 2.txt, 3.txt.......n.txt. Each file contains a
    > > single line of text. I need each line of text from all these source
    > > files to be appended into a single destination file called bulk.txt.
    > >
    > > I have found some marginally helpful stuff in the manpages and faqs
    > > but not quite what I need. Any pointers are appreciated.

    >
    > And your Perl question is ...?
    >
    > cat ?.txt > bulk.txt
    >
    > ought to do it.


    Dunno about the Perl question, but the Perl answer is

    perl -e'print while <>' ?.txt

    Anno
     
    Anno Siegel, May 7, 2004
    #4
  5. Steve

    Ian Wilson Guest

    Anno Siegel wrote:
    > A. Sinan Unur <> wrote in comp.lang.perl.misc:
    >
    >> (Steve) wrote in news:eb6d00cc.0405061257.5b167226
    >>@posting.google.com:
    >>
    >>
    >>>Hello,
    >>>
    >>>I have files 1.txt, 2.txt, 3.txt.......n.txt. Each file contains a
    >>>single line of text. I need each line of text from all these source
    >>>files to be appended into a single destination file called bulk.txt.
    >>>
    >>>I have found some marginally helpful stuff in the manpages and faqs
    >>>but not quite what I need. Any pointers are appreciated.

    >>
    >>And your Perl question is ...?
    >>
    >>cat ?.txt > bulk.txt
    >>
    >>ought to do it.

    >
    >
    > Dunno about the Perl question, but the Perl answer is
    >
    > perl -e'print while <>' ?.txt
    >
    > Anno


    And 'print while <>' is the -p option ...

    $ echo xxx > bulk.txt
    $ echo aaa > 1.txt
    $ echo bbb > 2.txt
    $ echo ccc > 3.txt
    $ perl -pe "" ?.txt >> bulk.txt
    $ cat bulk.txt
    xxx
    aaa
    bbb
    ccc

    I suppose this *might* be useful on a platform that has perl but lacks
    cat or a decent shell?
     
    Ian Wilson, May 7, 2004
    #5
  6. Ian Wilson <> wrote:

    > And 'print while <>' is the -p option ...
    >
    > $ echo xxx > bulk.txt
    > $ echo aaa > 1.txt
    > $ echo bbb > 2.txt
    > $ echo ccc > 3.txt
    > $ perl -pe "" ?.txt >> bulk.txt
    > $ cat bulk.txt
    > xxx
    > aaa
    > bbb
    > ccc
    >
    > I suppose this *might* be useful on a platform that has perl but
    > lacks cat or a decent shell?


    Sure, but even in later versions of DOS (at least v3+, IIRC) you
    could use

    C:\> for %f in (?.txt) do type %f >> bulk.txt

    and under win2k at least, 'type ?.txt > bulk.txt' seems to work as
    you might expect. The DOS shell is not completely brain-dead, just
    mentally retarded. :)

    Not that this has anything remotely to do with Perl...
     
    David K. Wall, May 7, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom
    Replies:
    7
    Views:
    455
    William Desrochers
    Sep 9, 2004
  2. Replies:
    4
    Views:
    1,001
    M.E.Farmer
    Feb 13, 2005
  3. John [H2O]
    Replies:
    2
    Views:
    299
    alex23
    Sep 22, 2008
  4. Stephanie S

    appending multiple PDFs together.

    Stephanie S, Jul 25, 2003, in forum: ASP General
    Replies:
    1
    Views:
    134
    Richard Choate
    Jul 25, 2003
  5. Paul Danese
    Replies:
    1
    Views:
    139
    Stefano Crocco
    Jun 14, 2007
Loading...

Share This Page