An unreadable one-liner: (I'll probably get downvoted for this :( )
perl -ple 'BEGIN { $/ = qq(\t); $x=0; @l=(); $y=1;} $l[$x]+=$_, $y++ for (split /\n/); } continue { $l[$x] /= $y, $y = 1, $x++ if eof; } for (@l) { ' *.txt > file.list
*.txt is the pattern of the input files, file.list is the output file. (you might need to change the single quotes to double quotes)
People that try to figure this one out: take a look at `perldoc perlrun` and `perldoc -f eof`
Update, removed 'close ARGV,' since it had no effect. (in my first attempt I used $., which is why it was there)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.