+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20

Add carriage return (new line character)

  1. Add carriage return (new line character)

    Hi Gurus,
    I have a file which has names each followed by semicolon(;). I need to
    replace each of his semicolon with new line character with sed.

    sample.txt
    test1;test2;test3;test4

    desired output:
    test1
    test2
    test3
    test4

    Any help is greatly appreciated.


  2. Re: Add carriage return (new line character)

    On Sun, 06 May 2007 09:59:14 -0700, explor wrote:

    > Hi Gurus,
    > I have a file which has names each followed by semicolon(;). I need to
    > replace each of his semicolon with new line character with sed.
    >
    > sample.txt
    > test1;test2;test3;test4
    >
    > desired output:
    > test1
    > test2
    > test3
    > test4
    >
    > Any help is greatly appreciated.


    Just use a substitution pattern ( s// ), there's no trap in
    this homework ;-)

  3. Re: Add carriage return (new line character)

    On May 6, 10:32 am, loki harfagr wrote:
    > On Sun, 06 May 2007 09:59:14 -0700, explor wrote:
    > > Hi Gurus,
    > > I have a file which has names each followed by semicolon(;). I need to
    > > replace each of his semicolon with new line character with sed.

    >
    > > sample.txt
    > > test1;test2;test3;test4

    >
    > > desired output:
    > > test1
    > > test2
    > > test3
    > > test4

    >
    > > Any help is greatly appreciated.

    >
    > Just use a substitution pattern ( s// ), there's no trap in
    > this homework ;-)


    Tried that doesn't work
    sed 's/;//g' sample.txt
    test1test2test3test4


  4. Re: Add carriage return (new line character)

    On Sun, 06 May 2007 10:48:59 -0700, explor wrote:

    > On May 6, 10:32 am, loki harfagr wrote:
    >> On Sun, 06 May 2007 09:59:14 -0700, explor wrote:
    >> > Hi Gurus,
    >> > I have a file which has names each followed by semicolon(;). I need
    >> > to replace each of his semicolon with new line character with sed.

    >>
    >> > sample.txt
    >> > test1;test2;test3;test4

    >>
    >> > desired output:
    >> > test1
    >> > test2
    >> > test3
    >> > test4

    >>
    >> > Any help is greatly appreciated.

    >>
    >> Just use a substitution pattern ( s// ), there's no trap in
    >> this homework ;-)

    >
    > Tried that doesn't work


    Of course it works :-)

    Though, exactly like you told 'it' to work:
    > sed 's/;//g' sample.txt
    > test1test2test3test4


    You asked sed to replace any semicolon by nothing ( // )
    just try with the synth char '\n' :-)

    OK, as my country just shot itself in the foot by 54/46
    and promoted hate and contempt I'll give a full answer now
    just to try and compensate ;-)

    $ echo "test1;test2;test3;test4" | sed 's/;/\n/g'
    test1
    test2
    test3
    test4

  5. Re: Add carriage return (new line character)

    explor wrote...
    >
    >On May 6, 10:32 am, loki harfagr wrote:
    >> On Sun, 06 May 2007 09:59:14 -0700, explor wrote:
    >> > Hi Gurus,
    >> > I have a file which has names each followed by semicolon(;). I need to
    >> > replace each of his semicolon with new line character with sed.

    >>
    >> > sample.txt
    >> > test1;test2;test3;test4

    >>
    >> > desired output:
    >> > test1
    >> > test2
    >> > test3
    >> > test4

    >>
    >> > Any help is greatly appreciated.

    >>
    >> Just use a substitution pattern ( s// ), there's no trap in
    >> this homework ;-)

    >
    >Tried that doesn't work
    >sed 's/;//g' sample.txt
    >test1test2test3test4


    Wiki Newline

    http://en.wikipedia.org/wiki/Newline




  6. Re: Add carriage return (new line character)

    On May 6, 11:47 am, loki harfagr wrote:
    > On Sun, 06 May 2007 10:48:59 -0700, explor wrote:
    > > On May 6, 10:32 am, loki harfagr wrote:
    > >> On Sun, 06 May 2007 09:59:14 -0700, explor wrote:
    > >> > Hi Gurus,
    > >> > I have a file which has names each followed by semicolon(;). I need
    > >> > to replace each of his semicolon with new line character with sed.

    >
    > >> > sample.txt
    > >> > test1;test2;test3;test4

    >
    > >> > desired output:
    > >> > test1
    > >> > test2
    > >> > test3
    > >> > test4

    >
    > >> > Any help is greatly appreciated.

    >
    > >> Just use a substitution pattern ( s// ), there's no trap in
    > >> this homework ;-)

    >
    > > Tried that doesn't work

    >
    > Of course it works :-)
    >
    > Though, exactly like you told 'it' to work:
    >
    > > sed 's/;//g' sample.txt
    > > test1test2test3test4

    >
    > You asked sed to replace any semicolon by nothing ( // )
    > just try with the synth char '\n' :-)
    >
    > OK, as my country just shot itself in the foot by 54/46
    > and promoted hate and contempt I'll give a full answer now
    > just to try and compensate ;-)
    >
    > $ echo "test1;test2;test3;test4" | sed 's/;/\n/g'
    > test1
    > test2
    > test3
    > test4


    Hi,
    I tried that first. N it doesn't work with Solaris sed.


  7. Re: Add carriage return (new line character)

    On May 6, 11:47 am, loki harfagr wrote:
    > On Sun, 06 May 2007 10:48:59 -0700, explor wrote:
    > > On May 6, 10:32 am, loki harfagr wrote:
    > >> On Sun, 06 May 2007 09:59:14 -0700, explor wrote:
    > >> > Hi Gurus,
    > >> > I have a file which has names each followed by semicolon(;). I need
    > >> > to replace each of his semicolon with new line character with sed.

    >
    > >> > sample.txt
    > >> > test1;test2;test3;test4

    >
    > >> > desired output:
    > >> > test1
    > >> > test2
    > >> > test3
    > >> > test4

    >
    > >> > Any help is greatly appreciated.

    >
    > >> Just use a substitution pattern ( s// ), there's no trap in
    > >> this homework ;-)

    >
    > > Tried that doesn't work

    >
    > Of course it works :-)
    >
    > Though, exactly like you told 'it' to work:
    >
    > > sed 's/;//g' sample.txt
    > > test1test2test3test4

    >
    > You asked sed to replace any semicolon by nothing ( // )
    > just try with the synth char '\n' :-)
    >
    > OK, as my country just shot itself in the foot by 54/46
    > and promoted hate and contempt I'll give a full answer now
    > just to try and compensate ;-)
    >
    > $ echo "test1;test2;test3;test4" | sed 's/;/\n/g'
    > test1
    > test2
    > test3
    > test4


    Here is what happens when i try that:
    echo "test;test2;test3;test4;" | sed 's/;/\n/g'
    testntest2ntest3ntest4n


  8. Re: Add carriage return (new line character)

    On May 6, 11:55 am, harryooopot...@hotmail.co_ (Harry331) wrote:
    > explor wrote...
    >
    > >On May 6, 10:32 am, loki harfagr wrote:
    > >> On Sun, 06 May 2007 09:59:14 -0700, explor wrote:
    > >> > Hi Gurus,
    > >> > I have a file which has names each followed by semicolon(;). I need to
    > >> > replace each of his semicolon with new line character with sed.

    >
    > >> > sample.txt
    > >> > test1;test2;test3;test4

    >
    > >> > desired output:
    > >> > test1
    > >> > test2
    > >> > test3
    > >> > test4

    >
    > >> > Any help is greatly appreciated.

    >
    > >> Just use a substitution pattern ( s// ), there's no trap in
    > >> this homework ;-)

    >
    > >Tried that doesn't work
    > >sed 's/;//g' sample.txt
    > >test1test2test3test4

    >
    > Wiki Newline
    >
    > http://en.wikipedia.org/wiki/Newline

    Sorry the above link too doesn't help on Solaris sed. I tried tr as
    well

    tr '\n\' sample1.txt
    no difference.



  9. Re: Add carriage return (new line character)

    explor wrote:
    > Hi Gurus,
    > I have a file which has names each followed by semicolon(;). I need to
    > replace each of his semicolon with new line character with sed.
    >
    > sample.txt
    > test1;test2;test3;test4
    >
    > desired output:
    > test1
    > test2
    > test3
    > test4
    >
    > Any help is greatly appreciated.


    $ echo "test1;test2;test3;test4" | perl -lp073e1
    test1
    test2
    test3
    test4



    John
    --
    Perl isn't a toolbox, but a small machine shop where you can special-order
    certain sorts of tools at low cost and in short order. -- Larry Wall

  10. Re: Add carriage return (new line character)

    On 2007-05-06, explor wrote:
    > Hi Gurus,
    > I have a file which has names each followed by semicolon(;). I need to
    > replace each of his semicolon with new line character with sed.
    >
    > sample.txt
    > test1;test2;test3;test4
    >
    > desired output:
    > test1
    > test2
    > test3
    > test4


    sed 's/;/\
    /g' sample.txt

    --
    Chris F.A. Johnson, author
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
    ===== My code in this post, if any, assumes the POSIX locale
    ===== and is released under the GNU General Public Licence

+ Reply to Thread
Page 1 of 2 1 2 LastLast