I love sed

Chat about Linux in general
Post Reply
User avatar
Level 5
Level 5
Posts: 737
Joined: Fri Nov 19, 2010 4:55 pm
Location: Warrington, UK

I love sed

Post by Roken »

Is it just me. Ever since I started playing with sed I find myself relishing those little challenging questions that pop up on forums for a sed solution to some problem, simply because it's a bit like a game and a brain teaser.

Am I the only one?

Edit: this is my latest - and I'm the first to come up with a pure sed solution. Not gonna tell you what it does, you can work that out for yourself :)

Code: Select all

sed -i -e '1,1d' -e '$d' -e 's/.* \([0-9]*\) .*/\1,/g' test.txt;  sed -i '$s/.$//' test.txt
Kernel Linux Tex 4.8.13-1-ARCH (64 bit) xfce , burg
GTX680 4Gb
AMD Phenom II X4 (965BE) @ 3.6 Ghz
User avatar
Level 24
Level 24
Posts: 24922
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: I love sed

Post by xenopeek »

I love what you can do with sed, but I'm not looking for "braintraining" :roll: Got enough thinking to do without decoding sed one liners 8) (Or do you cheat and use the manpage :wink:)

Its amazing what tools the command line hides, until you find them. I found sed years ago after hunting for some way to have grep output lines from a starting line match to an ending line match. sed can do that so easily... (as: sed -n '/startlineregexp/,/endinglineregexp/p')

On the same note, I needed to find what form data a webpage was posting to the server. Was hunting around for tools, and yes, it is again a one line command. I so much enjoy moments like that with Linux :mrgreen: (ngrep allows you to listen in on outgoing traffic, like this: sudo ngrep "POST" tcp and port 80)
Post Reply

Return to “Chat about Linux”