Re: okay, time to ask the wizards.

2010-10-28 Thread Chip Camden
Quoth Devin Teske on Thursday, 28 October 2010:
> On Thu, 2010-10-28 at 09:31 -0700, Gary Kline wrote:
> > On Thu, Oct 28, 2010 at 08:18:06AM -0500, Robert Bonomi wrote:
> > > 
> > > > From: Gary Kline 
> > > > To: FreeBSD Mailing List 
> > > > Cc: 
> > > > Subject: okay, time to ask the wizards.
> > > >
> > > > I've got a very large file with paragraphs separated only by "\n".
> > > > How do I put a blank line _after_ each newline?
> > > 
> > > have you tried something as simple as
> > > 
> > >sed -e 's/\n/&&/' outfile
> > > -or-
> > >awk  '{print; print "";}' infile
> > > --
> > >
> > 
> > 
> > There's another way, using awk.  :-)
> 
> 
> awk '{print $0"\n"}'
> 
> ^_^
> 

Birdie -- but,

sed G

is an eagle.

-- 
Sterling (Chip) Camden| sterl...@camdensoftware.com | 2048D/3A978E4F
http://camdensoftware.com | http://chipstips.com| http://chipsquips.com


pgp9qhMaK4X6u.pgp
Description: PGP signature


Re: okay, time to ask the wizards.

2010-10-28 Thread Devin Teske
On Thu, 2010-10-28 at 09:31 -0700, Gary Kline wrote:
> On Thu, Oct 28, 2010 at 08:18:06AM -0500, Robert Bonomi wrote:
> > 
> > > From: Gary Kline 
> > > To: FreeBSD Mailing List 
> > > Cc: 
> > > Subject: okay, time to ask the wizards.
> > >
> > > I've got a very large file with paragraphs separated only by "\n".
> > > How do I put a blank line _after_ each newline?
> > 
> > have you tried something as simple as
> > 
> >sed -e 's/\n/&&/' outfile
> > -or-
> >awk  '{print; print "";}' infile
> > --
> >
> 
> 
>   There's another way, using awk.  :-)


awk '{print $0"\n"}'

^_^



>   gary
> 
> 
> > 
> > ___
> > freebsd-questions@freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

-- 
Cheers,
Devin Teske

-> CONTACT INFORMATION <-
Business Solutions Consultant II
FIS - fisglobal.com
510-735-5650 Mobile
510-621-2038 Office
510-621-2020 Office Fax
909-477-4578 Home/Fax
devin.te...@fisglobal.com

-> LEGAL DISCLAIMER <-
This message  contains confidential  and proprietary  information
of the sender,  and is intended only for the person(s) to whom it
is addressed. Any use, distribution, copying or disclosure by any
other person  is strictly prohibited.  If you have  received this
message in error,  please notify  the e-mail sender  immediately,
and delete the original message without making a copy.

-> FUN STUFF <-
-BEGIN GEEK CODE BLOCK-
Version 3.1
GAT/CS d(+) s: a- C++() UB$ P++() L++() !E--- W++ N? o? K- w O
M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ e>+ h
r>++ y+ 
--END GEEK CODE BLOCK--
http://www.geekcode.com/

-> END TRANSMISSION <-

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-28 Thread Gary Kline
On Thu, Oct 28, 2010 at 08:18:06AM -0500, Robert Bonomi wrote:
> 
> > From: Gary Kline 
> > To: FreeBSD Mailing List 
> > Cc: 
> > Subject: okay, time to ask the wizards.
> >
> > I've got a very large file with paragraphs separated only by "\n".
> > How do I put a blank line _after_ each newline?
> 
> have you tried something as simple as
> 
>sed -e 's/\n/&&/' outfile
> -or-
>awk  '{print; print "";}' infile
> --
>


There's another way, using awk.  :-)

gary


> 
> ___
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
The 7.90a release of Jottings: http://jottings.thought.org/index.php
   http://journey.thought.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-28 Thread Gary Kline
On Thu, Oct 28, 2010 at 03:18:02PM +1030, Wayne Sierke wrote:
> On Wed, 2010-10-27 at 18:16 -0700, Liontaur wrote:
> > On Wed, Oct 27, 2010 at 6:04 PM, Gary Kline  wrote:
> > 
> > > I've got a very large file with paragraphs separated only by "\n".
> > > How do I put a blank line _after_ each newline?
> > >
> > >
> > Perhaps using sed? i'm definitely no sed expert but the substitute command
> > would work, just substitute one \n with two?
> > 
> > Mark
> 
> Not quite. When considering sed(1), recall that:
> 
> Normally, sed cyclically copies a line of input, not including
> its terminating newline character, into a pattern space, ...
> (then) copies the pattern space to the standard output,
> appending a newline, and deletes the pattern space.
> 
> So there is no "\n" in the initial pattern space to be substituted.
> Characters can however be inserted at the end of the line (before the
> original \n) with: "s/$//" as Chad used in his perl
> solution. Unfortunately FreeBSD sed's "substitute" doesn't recognise
> "\n" as "newline"  in a substitution, although it's possible to insert a
> literal "newline" character through various shell-dependent techniques.
> 
> In this particular case however, sed does offer the "pièce de
> résistance":
> 
> sed G
> 
> 
> The operation is left as a learning exercise for the reader.
> 
> 
> Wayne
> 


Well, I hope this mouse and paste works across konsoles.  I've
had this stuff in my ~/.HowTo file for a couple years.  I don't
remember the  % sed G bit, but it would've saved a lot of electrons.


%%% sed howto's:

FILE SPACING:

 # double space a file
 sed G

 # double space a file which already has blank lines in it. Output
file
 # should contain no more than one blank line between lines of text.
 sed '/^$/d;G'

 # triple space a file
 sed 'G;G'


Yup.  Works.  So there, gents, you've got it from "wherever I
got it from."

thanks for the insights from ``y'all|you-all|you'n's|everybody''

gary



> 

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
The 7.90a release of Jottings: http://jottings.thought.org/index.php
   http://journey.thought.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-28 Thread Wayne Sierke
On Thu, 2010-10-28 at 15:18 +1030, Wayne Sierke wrote:
> > On Wed, Oct 27, 2010 at 6:04 PM, Gary Kline  wrote:
> > 
> > > I've got a very large file with paragraphs separated only by "\n".
> > > How do I put a blank line _after_ each newline?

> In this particular case however, sed does offer the "pièce de
> résistance":
> 
> sed G

Mea culpa. Someone contacted me off-list querying the validity of my sed
statement which highlighted that my solution description was overly
terse.

Of course what I was suggesting was:

sed G sourcefile

and practically used as something like:

sed G sourcefile > newfile

or:

sed -i .orig -e G sourcefile

e.g.:

%cat > sourcefile
Line one.
Line two.   
Line three.
%D
%sed G sourcefile
Line one.

Line two.   

Line three.

%


Wayne


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-28 Thread Robert Bonomi

> From: Gary Kline 
> To: FreeBSD Mailing List 
> Cc: 
> Subject: okay, time to ask the wizards.
>
> I've got a very large file with paragraphs separated only by "\n".
> How do I put a blank line _after_ each newline?

have you tried something as simple as

   sed -e 's/\n/&&/' outfile
-or-
   awk  '{print; print "";}' infile
--
   

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards..

2010-10-28 Thread perryh
Chad Perrin  wrote:

> Plus . . . I like pie.

A bit out of season, aren't we?  It's nowhere near 1 minute before 2
on March 14.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-27 Thread Gary Kline
On Wed, Oct 27, 2010 at 07:29:25PM -0600, Chad Perrin wrote:
> On Wed, Oct 27, 2010 at 06:14:04PM -0700, Nerius Landys wrote:
> > You mean replace each newline character with two newline characters?
> > 
> > perl -p -i -e 's/\n/\n\n/g' yourfile.txt
> 

Hm.  Didn't think of perl; but yeah.

> The g in that is unnecessary.  I'd also be inclined to use $ in the
> matching part of that regex than \n, and only require one newline
> character in the substitution part as a result:
> 
> perl -pie 's/$/\n/' filename.txt


I think the '$' wins because there might be an embedded newline.
The pdf2html utility uses them to match the page-size of the
PDF.
> 
> Plus . . . I like pie.


Yup.

-g

> 
> -- 
> Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]



-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
The 7.90a release of Jottings: http://jottings.thought.org/index.php
   http://journey.thought.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-27 Thread Gary Kline
On Wed, Oct 27, 2010 at 07:10:55PM -0600, Chad Perrin wrote:
> On Wed, Oct 27, 2010 at 06:04:50PM -0700, Gary Kline wrote:
> > I've got a very large file with paragraphs separated only by "\n".
> > How do I put a blank line _after_ each newline?
> 
> perl -e 'while (<>) { s/$/\n/; print; }'
> 
> You could also open the file in vi or Vim and give it this command:
> 
> :%s/$/^M/
> 
> Note that you don't type in that ^M by using the ^ and M keys on the
> keyboard.  Instead, you first type ctrl-v then press the Enter key.
> 


Thanks, much  I've been editing the entire day [[ well, before
I stopped to watch the ST DVD:-)]].  Then trying to remember how the 
hell to get a newline into a vi :sub.  There is a way using tr that
is among the tr man page examples.  Not sure that will work.

I'll put your perl exaple with -pi.bak into my ~/bin directory.
That way, when my brain stalls I'll have it.

gary

PS:  There are a few remaining regex tricks that I have to catch
before I run the file thru atom.  For now: calling "T"--

> -- 
> Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]



-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
The 7.90a release of Jottings: http://jottings.thought.org/index.php
   http://journey.thought.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-27 Thread Wayne Sierke
On Wed, 2010-10-27 at 18:16 -0700, Liontaur wrote:
> On Wed, Oct 27, 2010 at 6:04 PM, Gary Kline  wrote:
> 
> > I've got a very large file with paragraphs separated only by "\n".
> > How do I put a blank line _after_ each newline?
> >
> >
> Perhaps using sed? i'm definitely no sed expert but the substitute command
> would work, just substitute one \n with two?
> 
> Mark

Not quite. When considering sed(1), recall that:

Normally, sed cyclically copies a line of input, not including
its terminating newline character, into a pattern space, ...
(then) copies the pattern space to the standard output,
appending a newline, and deletes the pattern space.

So there is no "\n" in the initial pattern space to be substituted.
Characters can however be inserted at the end of the line (before the
original \n) with: "s/$//" as Chad used in his perl
solution. Unfortunately FreeBSD sed's "substitute" doesn't recognise
"\n" as "newline"  in a substitution, although it's possible to insert a
literal "newline" character through various shell-dependent techniques.

In this particular case however, sed does offer the "pièce de
résistance":

sed G


The operation is left as a learning exercise for the reader.


Wayne


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-27 Thread Chad Perrin
On Wed, Oct 27, 2010 at 06:14:04PM -0700, Nerius Landys wrote:
> You mean replace each newline character with two newline characters?
> 
> perl -p -i -e 's/\n/\n\n/g' yourfile.txt

The g in that is unnecessary.  I'd also be inclined to use $ in the
matching part of that regex than \n, and only require one newline
character in the substitution part as a result:

perl -pie 's/$/\n/' filename.txt

Plus . . . I like pie.

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]


pgpGpP9Q2VWV4.pgp
Description: PGP signature


Re: okay, time to ask the wizards.

2010-10-27 Thread Chad Perrin
On Wed, Oct 27, 2010 at 06:04:50PM -0700, Gary Kline wrote:
> I've got a very large file with paragraphs separated only by "\n".
> How do I put a blank line _after_ each newline?

perl -e 'while (<>) { s/$/\n/; print; }'

You could also open the file in vi or Vim and give it this command:

:%s/$/^M/

Note that you don't type in that ^M by using the ^ and M keys on the
keyboard.  Instead, you first type ctrl-v then press the Enter key.

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]


pgpaTw6st1UGV.pgp
Description: PGP signature


Re: okay, time to ask the wizards.

2010-10-27 Thread Liontaur
On Wed, Oct 27, 2010 at 6:04 PM, Gary Kline  wrote:

> I've got a very large file with paragraphs separated only by "\n".
> How do I put a blank line _after_ each newline?
>
>
Perhaps using sed? i'm definitely no sed expert but the substitute command
would work, just substitute one \n with two?

Mark
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: okay, time to ask the wizards.

2010-10-27 Thread Nerius Landys
You mean replace each newline character with two newline characters?

perl -p -i -e 's/\n/\n\n/g' yourfile.txt

Something like that?

On Wed, Oct 27, 2010 at 6:04 PM, Gary Kline  wrote:

> I've got a very large file with paragraphs separated only by "\n".
> How do I put a blank line _after_ each newline?
>
>
>
> --
>  Gary Kline  kl...@thought.org  http://www.thought.org  Public Service
> Unix
>The 7.90a release of Jottings: http://jottings.thought.org/index.php
>   http://journey.thought.org
>
> ___
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "
> freebsd-questions-unsubscr...@freebsd.org"
>
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


okay, time to ask the wizards.

2010-10-27 Thread Gary Kline
I've got a very large file with paragraphs separated only by "\n".
How do I put a blank line _after_ each newline?



-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
The 7.90a release of Jottings: http://jottings.thought.org/index.php
   http://journey.thought.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"