newbie; appending multiple files

S

Steve

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
 
A

A. Sinan Unur

(e-mail address removed) (Steve) wrote in @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.
 
J

John W. Krahn

A. Sinan Unur said:
(e-mail address removed) (Steve) wrote in @posting.google.com:

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
 
A

Anno Siegel

A. Sinan Unur said:
(e-mail address removed) (Steve) wrote in @posting.google.com:


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
 
I

Ian Wilson

Anno said:
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?
 
D

David K. Wall

Ian Wilson said:
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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top