Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > newbie; appending multiple files

Reply
Thread Tools

newbie; appending multiple files

 
 
Steve
Guest
Posts: n/a
 
      05-06-2004
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
 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      05-06-2004
(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)
 
Reply With Quote
 
 
 
 
John W. Krahn
Guest
Posts: n/a
 
      05-06-2004
"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
 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      05-07-2004
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
 
Reply With Quote
 
Ian Wilson
Guest
Posts: n/a
 
      05-07-2004
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?

 
Reply With Quote
 
David K. Wall
Guest
Posts: n/a
 
      05-07-2004
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...
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
appending * to glob returns files with '*' !! John [H2O] Python 2 09-21-2008 11:50 PM
appending the contents of multiple text files into 1 file Paul Danese Ruby 1 06-14-2007 04:25 PM
Text files read multiple files into single file, and then recreate the multiple files googlinggoogler@hotmail.com Python 4 02-13-2005 05:44 PM
Need help appending html code to many html files. Tom HTML 7 09-08-2004 11:55 PM
appending multiple PDFs together. Stephanie S ASP General 1 07-25-2003 04:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57