Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: unhead and untail

by dmitri (Curate)
on Apr 15, 2003 at 19:54 UTC ( #250662=note: print w/ replies, xml ) Need Help??


in reply to unhead and untail

A couple of thoughts:

The cutting up of input stream as you describe can be much done much easier with sed, for instance, instead of

query-students | sort | unhead '^D' | untail '^G'
do
query-students | sort | sed '/^D/,/^G/p; d'
Also, neither head nor tail modify files they operate on. I understand, you were probably solving a specific problem, but this script can be generalized even more.


Comment on Re: unhead and untail
Select or Download Code
Re^2: unhead and untail (GNU sed -i)
by Aristotle (Chancellor) on Apr 15, 2003 at 20:09 UTC
    unhead is superfluous even with inplace editing given recent versions of GNU sed, as they sport an -i switch for inplace editing just like Perl has. What you still can't do with sed is specify "X lines before end of file" addresses.

    Makeshifts last the longest.

      > What you still can't do with sed is specify "X lines before end of file" addresses.

      Neither can this utility, read the description.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2015-07-06 11:22 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 (72 votes), past polls