Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Deleting lines prior to a date!

by davidj (Priest)
on May 10, 2006 at 02:46 UTC ( #548368=note: print w/ replies, xml ) Need Help??


in reply to Deleting lines prior to a date!

Use the range operator: start at line 1 and stop when you reach the date you are looking for.
As others have assumed, this assumes that the lines are in calendar order.

www:davidj test > cat t.txt TICKETHELP###,########,1234567###,2004,1,2,35.00###,2004-5-2 17:44:44, + +TICKETHELP###########1234567###2005XY356.00###,World Cup List,John +Ma +rck TICKETHELP###,########,1234567###,2005,3,4,16.00###,2005-3-8 17:44:44, + +TICKETHELP###########1234567###2005XY356.00###,World Cup List,John +Ma +rck TICKETHELP###,########,1234567###,2006,5,6,23.00###,2006-1-3 17:44:44, + +TICKETHELP###########1234567###2005XY356.00###,World Cup List,John +Ma +rck TICKETHELP###,########,0933456###,2005,7,8,33.00###,2005-5-7 17:44:44, + +TICKETHELP###########1234567###2005XY356.00###,World Cup List,John +Ma +rck TICKETHELP###,########,1234567###,2005,9,10,87.00###,2005-5-4 17:44:44 + +,TICKETHELP###########1234567###2005XY356.00###,World Cup List,John + M +arck TICKETHELP###,########,1984567###,2005,11,12,32.00###,2005-3-8 17:44:4 + +4,TICKETHELP###########1234567###2005XY356.00###,World Cup List,Joh +n +Marck TICKETHELP###,########,1234567###,2005,13,14,67.00###,2006-5-2 17:44:4 + +4,TICKETHELP###########1234567###2005XY356.00###,World Cup List,Joh +n +Marck TICKETHELP###,########,1223698###,2000,15,16,79.00###,2000-1-1 17:44:4 + +4,TICKETHELP###########1234567###2005XY356.00###,World Cup List,Joh +n +Marck TICKETHELP###,########,1299n67###,2001,17,18,26.00###,2001-5-5 17:44:4 + +4,TICKETHELP###########1234567###2005XY356.00###,World Cup List,Joh +n +Marck www:davidj test > cat t.pl #!/usr/bin/perl # open(FILE, "<t.txt"); open(OUT, ">out.txt"); while(<FILE>) { print OUT $_ if 1 .. /2005-5-4/; } close(OUT); close(FILE); www:davidj test > perl t.pl www:davidj test > cat out.txt TICKETHELP###,########,1234567###,2004,1,2,35.00###,2004-5-2 17:44:44, + +TICKETHELP###########1234567###2005XY356.00###,World Cup List,John +Ma +rck TICKETHELP###,########,1234567###,2005,3,4,16.00###,2005-3-8 17:44:44, + +TICKETHELP###########1234567###2005XY356.00###,World Cup List,John +Ma +rck TICKETHELP###,########,1234567###,2006,5,6,23.00###,2006-1-3 17:44:44, + +TICKETHELP###########1234567###2005XY356.00###,World Cup List,John +Ma +rck TICKETHELP###,########,0933456###,2005,7,8,33.00###,2005-5-7 17:44:44, + +TICKETHELP###########1234567###2005XY356.00###,World Cup List,John +Ma +rck TICKETHELP###,########,1234567###,2005,9,10,87.00###,2005-5-4 17:44:44 + +,TICKETHELP###########1234567###2005XY356.00###,World Cup List,John + M +arck www:davidj test >
Of course the line with the date you are looking for is included, but I'm sure you can figure out how to remove it.

davidj


Comment on Re: Deleting lines prior to a date!
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (19)
As of 2015-07-07 21:44 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 (93 votes), past polls