I claim to be a
`sed` lover, not guru (generally bad term), not geek. Since seders is closed private group (stupid, huh), i'd like to post something interesting and useful here.
Tutorials, i know, and could find in google all have silly examples and suck. Let's do a HOWTO for real-life stuff.
I did some comments deeply somewhere here about useful optimizations and tricks, now here's another one and more.
In this issue:
* changing all but last occurrence (persson)
* stripping slack from all php, htm*, css, js, xml on a production-level webserver (Julius Thyssen)
* per line transformations of blocks (David Esterkin, alhajaj), or i'm the best (-:
Message-ID: <email@example.com> Date: Tue, 22 Apr 2008 21:41:44 +0100 From: "Oleg Verych" <firstname.lastname@example.org> To: "sed users" <email@example.com> Subject: Re: Changing all but last occurrence persson @ Tue, Apr 22, 2008 at 6:18 PM: > > Why do you need this? And why you don't try to code anything yourself? > > It's precisely because I tried and can't see a way to accomplish the goal > using sed alone that I'm asking here. I already know how to do those > things using other tools or sed + other tools, but not with sed alone, > so I'm asking whether that is possible at all or I'm just missing > something. Anyway a working showcase of what you want is always better (if you have it), than words and vague descriptions. > > > - match/change all but last n occurrences of RE *in a file*, RE > > > occurs at > > > > > > most once per input line; > > [...] > > > many times per input line; > > > > If operating whole file, number of per-line occurrences doesn't > > matter. > > Can you elaborate on this? Here's what i think about this task. Curiosity can elaborate it. ftp://flower.upol.cz/dts/sed0000_var/all_but.sed.sh $ sh all_but.sed.sh $ sh all_but.sed.sh a 22 $ sh all_but.sed.sh l $ sh all_but.sed.sh l 22 --