Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Merging files, 1 line for every 10

by JavaFan (Canon)
on Sep 06, 2011 at 21:53 UTC ( #924472=note: print w/ replies, xml ) Need Help??


in reply to Merging files, 1 line for every 10

I wouldn't use Perl for something so trivial - that's easily done in a shell one-liner. I'll give a shell (bash) solution, porting it to Perl is left as an exercise for the reader. Assume the names of the two files are in variables $FILE1 and $FILE2.

sort -n -k1,1 <(nl -ba -i2 -v1 $FILE1) <(nl -ba -i20 -v0 $FILE2) | c +ut -f2-


Comment on Re: Merging files, 1 line for every 10
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924472]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (14)
As of 2015-07-30 18:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls