Re: A general sed question

2009-10-07 Thread George Davidovich
On Tue, Oct 06, 2009 at 11:45:36PM -0700, David Allen wrote: > I keep bumping up against this, so I thought I'd throw this question out > to those who understand sed better than I do. > > What I'm trying to do is to clean up the contents of some files > (/sys/i386/conf/GENERIC would be a good exam

Re: A general sed question

2009-10-07 Thread Oliver Fromme
David Allen wrote: > I keep bumping up against this, so I thought I'd throw this question out > to those who understand sed better than I do. > > What I'm trying to do is to clean up the contents of some files > (/sys/i386/conf/GENERIC would be a good example) to get more readable > diffs.

Re: A general sed question

2009-10-07 Thread Nerius Landys
Uh, I know I'm stating the obvious, but you might try these 2 techniques to enhance your diff experience: 1. Use "diff -w". 2. Do "cat filename | sort > filename.sorted" for both files you are diffing, and then compare both sorted files. ___ freebsd-ques

A general sed question

2009-10-06 Thread David Allen
I keep bumping up against this, so I thought I'd throw this question out to those who understand sed better than I do. What I'm trying to do is to clean up the contents of some files (/sys/i386/conf/GENERIC would be a good example) to get more readable diffs. To that end, I'm trying to use sed to

Re: Sed question

2008-12-23 Thread Matthew Seaman
Gary Kline wrote: On Mon, Dec 22, 2008 at 08:53:36AM +, Matthew Seaman wrote: Gary Kline wrote: anyway, this is one for giiorgos, or another perl wiz. i've been using the perl subsitution cmd one-liner for years with unfailing success. is there a way of deleting li

Re: Sed question

2008-12-23 Thread Gary Kline
On Mon, Dec 22, 2008 at 08:53:36AM +, Matthew Seaman wrote: > Gary Kline wrote: > > > anyway, this is one for giiorgos, or another perl wiz. i've > > been using the perl subsitution cmd one-liner for years with > > unfailing success. is there a way of deleting lines with perl > >

Re: Sed question

2008-12-22 Thread Matthew Seaman
Gary Kline wrote: anyway, this is one for giiorgos, or another perl wiz. i've been using the perl subsitution cmd one-liner for years with unfailing success. is there a way of deleting lines with perl using the same idea as: perl -pi.bak -e 's/OLDSTRIN

Re: Sed question

2008-12-22 Thread Jonathan McKeown
On Monday 22 December 2008 00:27:44 Gary Kline wrote: > > anyway, this is one for giiorgos, or another perl wiz. i've > been using the perl subsitution cmd one-liner for years with > unfailing success. is there a way of deleting lines with perl > using the same idea as: > >

Re: Sed question

2008-12-21 Thread Polytropon
On Mon, 22 Dec 2008 05:31:08 +0200, Giorgos Keramidas wrote: > On Sun, 21 Dec 2008 14:27:44 -0800, Gary Kline wrote: > > perl -pi.bak -e 's/OLDSTRING/NEWSTRING/g' file1 file2 fileN > > > > that i swiped somewhere. [?] > > > > last night i was up until the wee hours coding or e

Re: Sed question

2008-12-21 Thread Giorgos Keramidas
On Sun, 21 Dec 2008 14:27:44 -0800, Gary Kline wrote: > perl -pi.bak -e 's/OLDSTRING/NEWSTRING/g' file1 file2 fileN > > that i swiped somewhere. [?] > > last night i was up until the wee hours coding or extending > a c++ program to assist in this stuff. while i re

Re: Sed question

2008-12-21 Thread Gary Kline
On Sun, Dec 21, 2008 at 03:06:58PM +0100, Bertram Scharpf wrote: > Hi, > > Am Sonntag, 21. Dez 2008, 02:08:04 -0800 schrieb Gary Kline: > > On Sun, 2008-12-21 at 07:42 +0200, Giorgos Keramidas wrote: > > > On Sat, 20 Dec 2008 21:34:10 -0800, Gary Kline wrote: > > > > > > > > sed '8,10d'< file> ne

Re: Sed question

2008-12-21 Thread Bertram Scharpf
Hi, Am Sonntag, 21. Dez 2008, 02:08:04 -0800 schrieb Gary Kline: > On Sun, 2008-12-21 at 07:42 +0200, Giorgos Keramidas wrote: > > On Sat, 20 Dec 2008 21:34:10 -0800, Gary Kline wrote: > > > > > > sed '8,10d'< file> newfile > > > or is there a better way? > > > > keram...@kobe:/tmp$ sed -i ''

Re: Sed question

2008-12-21 Thread Gary Kline
On Sun, 2008-12-21 at 07:42 +0200, Giorgos Keramidas wrote: > On Sat, 20 Dec 2008 21:34:10 -0800, Gary Kline wrote: > > how can i delete, say, lines 8,9,and 10 from 200 files > > using sed? Is it > > > > sed '8,10d'< file> newfile > > or is there a better way? > > Use in-place editing: > > ke

Re: Sed question

2008-12-20 Thread Corey Chandler
Gary Kline wrote: how can i delete, say, lines 8,9,and 10 from 200 files using sed? Is it sed '8,10d'< file> newfile or is there a better way? I'd stick it in a for loop using inplace editing, but yes. :-) ___ fre

Re: Sed question

2008-12-20 Thread prad
On Sat, 20 Dec 2008 21:34:10 -0800 Gary Kline wrote: > or is there a better way? > nothing specific to add for your particular issue, but this link may be useful in the future for sed: http://sed.sourceforge.net/grabbag/tutorials/ -- In friendship, prad ..

Re: Sed question

2008-12-20 Thread Giorgos Keramidas
On Sat, 20 Dec 2008 21:34:10 -0800, Gary Kline wrote: > how can i delete, say, lines 8,9,and 10 from 200 files > using sed? Is it > > sed '8,10d'< file> newfile > or is there a better way? Use in-place editing: keram...@kobe:/tmp$ cat -n foo 1 foo 2 bar 3 baz keram..

Sed question

2008-12-20 Thread Gary Kline
how can i delete, say, lines 8,9,and 10 from 200 files using sed? Is it sed '8,10d'< file> newfile or is there a better way? tia, gary -- Gary Kline kl...@thought.org http://www.thought.org Public Service Unix http://jottings.thoug

Re: A sed question

2008-07-09 Thread Unga
--- On Wed, 7/9/08, Bertram Scharpf <[EMAIL PROTECTED]> wrote: > From: Bertram Scharpf <[EMAIL PROTECTED]> > Subject: Re: A sed question > To: "Unga" <[EMAIL PROTECTED]>, freebsd-questions@freebsd.org > Date: Wednesday, July 9, 2008, 6:52 PM > Hii, >

Re: A sed question

2008-07-09 Thread Bertram Scharpf
Hii, Am Mittwoch, 09. Jul 2008, 00:35:32 -0700 schrieb Unga: > I want to translate following GNU sed lines to FreeBSD sed: > > 1. sed -e '/\*address:/{n;[EMAIL PROTECTED]@replaceText @}' > 2. sed -e '/\*address:/{n;[EMAIL PROTECTED]@ [EMAIL PROTECTED]' An obvious problem is that a semicolon is m

A sed question

2008-07-09 Thread Unga
Hi all I want to translate following GNU sed lines to FreeBSD sed: 1. sed -e '/\*address:/{n;[EMAIL PROTECTED]@replaceText @}' 2. sed -e '/\*address:/{n;[EMAIL PROTECTED]@ [EMAIL PROTECTED]' Appreciate if someone could help with it. Is there a good documentation about FreeBSD sed other than ma

Re: sed question...

2007-09-25 Thread Giorgos Keramidas
On 2007-09-25 22:49, Pollywog <[EMAIL PROTECTED]> wrote: > On Tuesday 25 September 2007 22:21:48 Giorgos Keramidas wrote: > > A word of caution there... > > > > If you plan to use GNU/Linux manpages for learning sed(1) be _very_ > > cautious for GNU/Linux-specific parts. There are subtle, yet > >

Re: sed question...

2007-09-25 Thread Pollywog
On Tuesday 25 September 2007 22:21:48 Giorgos Keramidas wrote: > > A word of caution there... > > If you plan to use GNU/Linux manpages for learning sed(1) be _very_ > cautious for GNU/Linux-specific parts. There are subtle, yet possibly > important differences between GNU/Linux sed and BSD sed.

Re: sed question...

2007-09-25 Thread Gary Kline
On Wed, Sep 26, 2007 at 01:21:48AM +0300, Giorgos Keramidas wrote: > On 2007-09-25 11:28, Gary Kline <[EMAIL PROTECTED]> wrote: > > Thank you! This will help me de-code that sed one-liner that was > > evidently written by a sedexpert. The linux pages help further, but > > I've found some soild tut

Re: sed question...

2007-09-25 Thread Giorgos Keramidas
On 2007-09-25 11:28, Gary Kline <[EMAIL PROTECTED]> wrote: > Thank you! This will help me de-code that sed one-liner that was > evidently written by a sedexpert. The linux pages help further, but > I've found some soild tutorials. Hi Gary. A word of caution there... If you plan to use GNU/Lin

Re: sed question...

2007-09-25 Thread Gary Kline
On Tue, Sep 25, 2007 at 08:50:57PM +0300, Nikos Vassiliadis wrote: > Gary, > > This will probably help you, it has many nice one-liners. > > http://sed.sourceforge.net/grabbag/tutorials/sed1line.txt > > Nikos Aww, you found my stash:) But as I said, up-queue, I'm overdue to u

Re: sed question...

2007-09-25 Thread Gary Kline
On Tue, Sep 25, 2007 at 08:38:50PM +0300, Nikos Vassiliadis wrote: > On Tuesday 25 September 2007 19:58, Gary Kline wrote: > > But trying to parse this from man sed is more than > > difficule. And I have yet to find "ba" in the man page. That is > > why I asked for some insights rathe

Re: sed question...

2007-09-25 Thread Nikos Vassiliadis
Gary, This will probably help you, it has many nice one-liners. http://sed.sourceforge.net/grabbag/tutorials/sed1line.txt Nikos ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe,

Re: sed question...

2007-09-25 Thread Nikos Vassiliadis
On Tuesday 25 September 2007 19:58, Gary Kline wrote: > But trying to parse this from man sed is more than > difficule. And I have yet to find "ba" in the man page. That is > why I asked for some insights rather that to be told to "go read > the man page"; to me, that's di

Re: sed question...

2007-09-25 Thread Gary Kline
On Tue, Sep 25, 2007 at 01:05:06PM -0400, Howard Goldstein wrote: > > > Giorgos Keramidas wrote: > > On 2007-09-24 20:52, Gary Kline <[EMAIL PROTECTED]> wrote: > > > >> On Mon, Sep 24, 2007 at 11:07:20PM -0400, Howard Goldstein wrote: > >> > # delete the last 10 lines of a file > >>

Re: sed question...

2007-09-25 Thread Gary Kline
On Tue, Sep 25, 2007 at 07:24:25PM +0300, Giorgos Keramidas wrote: > On 2007-09-24 20:52, Gary Kline <[EMAIL PROTECTED]> wrote: > >On Mon, Sep 24, 2007 at 11:07:20PM -0400, Howard Goldstein wrote: > >>> # delete the last 10 lines of a file > >>> sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1 >

Re: sed question...

2007-09-25 Thread Howard Goldstein
Giorgos Keramidas wrote: > On 2007-09-24 20:52, Gary Kline <[EMAIL PROTECTED]> wrote: > >> On Mon, Sep 24, 2007 at 11:07:20PM -0400, Howard Goldstein wrote: >> # delete the last 10 lines of a file sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1 sed -n -e :a -e '1,10!{P;

Re: sed question...

2007-09-25 Thread Gary Kline
On Tue, Sep 25, 2007 at 09:31:04AM +0300, Nikos Vassiliadis wrote: > On Tuesday 25 September 2007 06:07, Howard Goldstein wrote: > > Gary Kline wrote: > > > My earlier post about deleting the first N lines was answered by > > > this one-liner site {below}. I wasn't including any > > > redir

Re: sed question...

2007-09-25 Thread Giorgos Keramidas
On 2007-09-24 20:52, Gary Kline <[EMAIL PROTECTED]> wrote: >On Mon, Sep 24, 2007 at 11:07:20PM -0400, Howard Goldstein wrote: >>> # delete the last 10 lines of a file >>> sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1 >>> sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2 >>> >>> Question t

Re: sed question...

2007-09-24 Thread Nikos Vassiliadis
On Tuesday 25 September 2007 06:07, Howard Goldstein wrote: > Gary Kline wrote: > > My earlier post about deleting the first N lines was answered by > > this one-liner site {below}. I wasn't including any > > redirection; doing so finally resolved the problem. Now I need > > to d

Re: sed question...

2007-09-24 Thread Gary Kline
On Mon, Sep 24, 2007 at 11:07:20PM -0400, Howard Goldstein wrote: > Gary Kline wrote: > > My earlier post about deleting the first N lines was answered by > > this one-liner site {below}. I wasn't including any > > redirection; doing so finally resolved the problem. Now I need > >

Re: sed question...

2007-09-24 Thread Howard Goldstein
Gary Kline wrote: > My earlier post about deleting the first N lines was answered by > this one-liner site {below}. I wasn't including any > redirection; doing so finally resolved the problem. Now I need > to delete every line from the 19th or so to the last line. >

sed question...

2007-09-24 Thread Gary Kline
My earlier post about deleting the first N lines was answered by this one-liner site {below}. I wasn't including any redirection; doing so finally resolved the problem. Now I need to delete every line from the 19th or so to the last line. Question one, can

Re: sed question[s]

2007-09-24 Thread Giorgos Keramidas
On 2007-09-24 14:07, Gary Kline <[EMAIL PROTECTED]> wrote: > Hi, > I could probably do at least part of this with an ed shell > script, but sed is probaly more standard. (I may have asked this > before, years back: FWIW. Anyhow, don't see it in my > ~/Mail/freebsd files.) > > How can I automagica

sed question[s]

2007-09-24 Thread Gary Kline
Hi, I could probably do at least part of this with an ed shell script, but sed is probaly more standard. (I may have asked this before, years back: FWIW. Anyhow, don't see it in my ~/Mail/freebsd files.) How can I automagically delete from $1,155d

Re: [OT] sed question

2004-03-15 Thread Warren Block
On Mon, 15 Mar 2004, Parv wrote: > in message <[EMAIL PROTECTED]>, > wrote Warren Block thusly... > > > > perl -pe 's/\s./\n/g' my_test_text_document.txt > ^ > ^ > > Why do you have '.' after '\s'? Did you mean '+' instead? Oops--you're correct. \s+ for one or mo

Re: [OT] sed question

2004-03-15 Thread Parv
in message <[EMAIL PROTECTED]>, wrote Warren Block thusly... > > ...sed on other systems does handle \n and other literals in > substitutions. It's annoying enough that I just use Perl instead. > > perl -pe 's/ /\n/g' my_test_text_document.txt > > which actually would be better as > > perl -pe

Re: [OT] sed question

2004-03-15 Thread Dan Rue
On Sun, Mar 14, 2004 at 04:30:40PM -0600, Steven N. Fettig wrote: > Sorry for posting an off-topic question to the list, but this is > somethin that has been driving me nuts for weeks now and I can't figure > it out. I want to pass a text file through sed that replaces all > whitespaces with a

Re: [OT] sed question

2004-03-14 Thread Warren Block
On Sun, 14 Mar 2004, Rob Ellis wrote: > This works with sed in /bin/sh and ksh: > > sed -e 's/ */\ > /g' my_test_text_document.txt > > I.e., escape an actual newline. I used to do that, or include an actual newline in a script, but it just seems wrong from maintainability and readability standpo

Re: [OT] sed question

2004-03-14 Thread Bill Campbell
On Sun, Mar 14, 2004, Warren Block wrote: >On Sun, 14 Mar 2004, Steven N. Fettig wrote: > >> I can't figure out what the newline character is... I've tried \n \r &\, >> etc. with no avail. I run the following: >> >> sed 's/[ ]/\n/g' my_test_text_document.txt > >>From the sed man page: > >"2. The

Re: [OT] sed question

2004-03-14 Thread Rob Ellis
On Sun, Mar 14, 2004 at 04:50:40PM -0700, Warren Block wrote: > On Sun, 14 Mar 2004, Steven N. Fettig wrote: > > > I can't figure out what the newline character is... I've tried \n \r &\, > > etc. with no avail. I run the following: > > > > sed 's/[ ]/\n/g' my_test_text_document.txt > > >From th

Re: [OT] sed question

2004-03-14 Thread Warren Block
On Sun, 14 Mar 2004, Steven N. Fettig wrote: > I can't figure out what the newline character is... I've tried \n \r &\, > etc. with no avail. I run the following: > > sed 's/[ ]/\n/g' my_test_text_document.txt >From the sed man page: "2. The escape sequence \n matches a newline character embe

Re: [OT] sed question

2004-03-14 Thread Matthew Seaman
On Sun, Mar 14, 2004 at 04:30:40PM -0600, Steven N. Fettig wrote: > Sorry for posting an off-topic question to the list, but this is > somethin that has been driving me nuts for weeks now and I can't figure > it out. I want to pass a text file through sed that replaces all > whitespaces with a

[OT] sed question

2004-03-14 Thread Steven N. Fettig
Sorry for posting an off-topic question to the list, but this is somethin that has been driving me nuts for weeks now and I can't figure it out. I want to pass a text file through sed that replaces all whitespaces with a carriage return. I.e., if I have the file my_test_text_document.txt that

sed question

2003-02-16 Thread How Can ThisBe
Not directly FreeBSD question, however. Is it possible with sed (or awk) to turn this: i/in/1 2/3 4 5 6 into i/in/1 2/3456 The same syntax would also need to work on: i/in/1 2/x y z (result would be i/in/1 2/xyz) i/in/1 2 (result would be i/in/12) The closest I have gotten it to is: i/in/1 2/3

Re: stupid sed question

2002-11-07 Thread Mathew Kanner
On Nov 07, Paul A. Scott wrote: > > How about echo abc | tr 'b' '\n' ? > > tr substitutes characters only, while sed can work on arbitrary strings and > patterns. My guess is that the example was a simplified expression of a more > general requirement, in which case sed is appropriate and therefor

Re: stupid sed question

2002-11-07 Thread philipp
http://www.faqs.org/faqs/editor-faq/sed/ section 4.6 on Do, Nov 07, 2002 at 03:46:25pm -0500, Mathew Kanner wrote: > Hello, > I've been going nuts trying to figure out how to embed a > newline in sed, and the man page just doesn't mean anything to me. > > What I would like is > echo a

Re: stupid sed question

2002-11-07 Thread Paul A. Scott
> How about echo abc | tr 'b' '\n' ? tr substitutes characters only, while sed can work on arbitrary strings and patterns. My guess is that the example was a simplified expression of a more general requirement, in which case sed is appropriate and therefore, echo aaabbbccc | sed -e 's,bbb,\ ,' w

Re: stupid sed question

2002-11-07 Thread Paul A. Scott
On 11/7/02 12:46 PM, "Mathew Kanner" <[EMAIL PROTECTED]> wrote: > What I would like is > echo abc | sed -e's,b,\n' to get > a > c A script of the form: echo abc | sed -e 's,b,\ ,' will work if the newline is escaped with a backslash and the remainder of the sed substitute is on the next line.

Re: stupid sed question

2002-11-07 Thread Miguel Mendez
On Thu, 7 Nov 2002 15:46:25 -0500 Mathew Kanner <[EMAIL PROTECTED]> wrote: Hi, > I've been going nuts trying to figure out how to embed a > newline in sed, and the man page just doesn't mean anything to me. > > What I would like is > echo abc | sed -e's,b,\n' to get > a >

stupid sed question

2002-11-07 Thread Mathew Kanner
Hello, I've been going nuts trying to figure out how to embed a newline in sed, and the man page just doesn't mean anything to me. What I would like is echo abc | sed -e's,b,\n' to get a c Of course, the above doesn't work and I'm looking for an alternativ