add a newline character

add a newline character

Post by Frank Rizul » Tue, 28 Jan 1997 04:00:00



I have a text file with character strings separated by commas. I want to
create a second file with each character string on its own line. Using
sed, I think it's someting like this, but I can't quite get the proper
syntax for the newline character.

sed 's/,/\n/g' text.old > text.new

Thanks
Frank Rizulo

 
 
 

add a newline character

Post by Bill Marc » Wed, 29 Jan 1997 04:00:00



>I have a text file with character strings separated by commas. I want to
>create a second file with each character string on its own line. Using
>sed, I think it's someting like this, but I can't quite get the proper
>syntax for the newline character.

>sed 's/,/\n/g' text.old > text.new

(sh, ksh, bash)
sed 's/,/
/g' text.old > text.new

(csh,tcsh)
sed 's/,/\
/g' text.old > text.new

--
Bill Marcum    bmarcum at iglou dot com

spam than ever before.

 
 
 

add a newline character

Post by Simon Chamber » Wed, 29 Jan 1997 04:00:00


You don't need sed for this. Try

cat text.old | tr "," "\n" > text.new

 
 
 

add a newline character

Post by Brian S Hil » Wed, 29 Jan 1997 04:00:00



: : sed 's/,/\n/g' text.old > text.new
: (sh, ksh, bash)
: sed 's/,/
: /g' text.old > text.new
: (csh,tcsh)
: sed 's/,/\
: /g' text.old > text.new

Nope. That should be:

sed 's/,/\
/g' text.old    # for sh, ksh, and bash

sed 's/,/\\\
/g' text.old    # for csh, tcsh

-Brian
--
   ,---.     ,---.     ,---.     ,---.     ,---.     ,---.     ,---.  
  /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \  

__,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.__

 
 
 

add a newline character

Post by Randal Schwart » Fri, 14 Feb 1997 04:00:00


This Week's Useless Use of Cat Award goes to...

Simon> You don't need sed for this. Try
Simon> cat text.old | tr "," "\n" > text.new

And of course, if you've been following along for a week or two, you know
that this (BING!) is a Useless Use of Cat!

Rememeber, nearly all cases where you have:

        cat file | some_command and its args ...

you can rewrite it as:

        <file some_command and its args ...

Just another Useless Use of Usenet,

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me

 
 
 

add a newline character

Post by Dr.Dimitri Vulis KO » Sat, 15 Feb 1997 04:00:00



> This Week's Useless Use of Cat Award goes to...


> Simon> You don't need sed for this. Try
> Simon> cat text.old | tr "," "\n" > text.new

Do they have Usenet in jails, or is this guy out on parole?

---


Brighton Beach Boardwalk BBS, Forest Hills, N.Y.: +1-718-261-2013, 14.4Kbps
)

 
 
 

add a newline character

Post by robe » Sat, 15 Feb 1997 04:00:00




 >> This Week's Useless Use of Cat Award goes to...
 >Do they have Usenet in jails, or is this guy out on parole?

Uhm sorry, but what exactly has _your_ contribution been to the
Internet community?

                                                         robert