sed /5/d with as little blabbage

D

Dan Jacobson

Gentlemen, the challenge, to do as sed with as little blabbage,
$ seq 9|sed /5/d
$ seq 9|perl -ne 'next if /5/; print'
$ seq 9|perl -pe 'goto LINE if /5/'
Can I make it even shorter?

Perhaps this knows,
$ s2p '/5/d'|wc
123 459 2709
Never mind.
 
L

Lukas Mai

Abigail schrob:
Dan Jacobson ([email protected]) wrote on MMMCMLXXXIII September
MCMXCIII in <URL:.. Gentlemen, the challenge, to do as sed with as little blabbage,
.. $ seq 9|sed /5/d
.. $ seq 9|perl -ne 'next if /5/; print'
.. $ seq 9|perl -pe 'goto LINE if /5/'
.. Can I make it even shorter?
$ seq 9|perl -pe'$_=""if/5/'

TIMTOWTDI:
$ seq 9|perl -ne'/5/||print'
$ seq 9|perl -pe's/5\n//'

Lukas
 
U

Uri Guttman

LM> Abigail schrob:
LM> TIMTOWTDI:
LM> $ seq 9|perl -ne'/5/||print'
LM> $ seq 9|perl -pe's/5\n//'

that last one isn't the same thing. it only deletes the line if it is
just has (really just ends with) "5\n". the rest delete the line if it
has '5' in it.

uri
 
M

Michele Dondi

Dan Jacobson ([email protected]) wrote on MMMCMLXXXIII September
MCMXCIII in <URL:.. Gentlemen, the challenge, to do as sed with as little blabbage,
.. $ seq 9|sed /5/d
.. $ seq 9|perl -ne 'next if /5/; print'
.. $ seq 9|perl -pe 'goto LINE if /5/'
.. Can I make it even shorter?

$ seq 9|perl -pe'$_=""if/5/'

seq 9|perl -pe'$_ x=!/5/'
seq 9|perl -pe's/5.//s'


Michele
 
M

Michele Dondi

LM> $ seq 9|perl -ne'/5/||print'
LM> $ seq 9|perl -pe's/5\n//'

that last one isn't the same thing. it only deletes the line if it is
just has (really just ends with) "5\n". the rest delete the line if it
has '5' in it.

But since we're dealing with seq 9 here, both scripts produce the same
output so that they're most definitely equivalent per the OP's
request. And as far as I can say they would be similarly considered
completely equivalent by most golfing rules...


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top