Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

(OT) Re: Save all but line 32!

by JayBonci (Curate)
on Sep 19, 2002 at 07:59 UTC ( #199097=note: print w/replies, xml ) Need Help??

in reply to Save all but line 32!

Offtopic for the site, but sed's a much better tool for that job. It's very easy to do with sed addressing:
sed -n 32\!p filename
Sadly, I don't have a clever or shorter way to do it in perl. The number 32 can be anything, of course


Replies are listed 'Best First'.
Re^2: sed (was: Save all but line 32!)
by Aristotle (Chancellor) on Sep 19, 2002 at 18:57 UTC
    Golf time! :^) sed -e 32d filename

    Makeshifts last the longest.

      8 instead of 11 chars (excluding the filename) :^)

      t filename^G32^M^D^S

      T is my editor

      ^G32 := goto line 32

      ^M := return to terminate/execute the goto

      ^D := delete the line

      ^S := Save and exit!

      Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!
        It's 10 actually, I can leave out a space. sed -e32d filename Also, yours is 12 keystrokes. And once we get to multiple files, yours grows linearly, mine is constant.. :^) for F in *;do sed -e32d "$F";done (NB: a loop is necessary since we'll otherwise only delete the 32nd line of the first file.)

        Makeshifts last the longest.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2020-10-24 12:26 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (243 votes). Check out past polls.