Broken sed on 3.1.2a? - Minix

This is a discussion on Broken sed on 3.1.2a? - Minix ; Is sed broken on Minix 3.1.2a? For example, I need a small script that can just get the first character of any line: $ echo 123 45 6 | sed -e 's/\(^.\).*/\1/g' should return "1" on stdout. Is there something ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Broken sed on 3.1.2a?

  1. Broken sed on 3.1.2a?

    Is sed broken on Minix 3.1.2a? For example, I need a small script that
    can just get the first character of any line:

    $ echo 123 45 6 | sed -e 's/\(^.\).*/\1/g'

    should return "1" on stdout.

    Is there something about the Minix version of sed that I'm missing?

    Thanks in advance.


  2. Re: Broken sed on 3.1.2a?

    William M. Grim wrote:
    > Is sed broken on Minix 3.1.2a? For example, I need a small script that
    > can just get the first character of any line:


    > $ echo 123 45 6 | sed -e 's/\(^.\).*/\1/g'


    > should return "1" on stdout.


    > Is there something about the Minix version of sed that I'm missing?


    Not really, sed on Solaris does not print "1" on stdout either, but "123
    45 6". I suppose that is the output you get on Minix as well, right? Try
    placing the caret ('^') before the parentheses instead of inside them, it
    helps on Solaris.

    Jens

    --
    Jens de Smit
    Student Computer Science | Vrije Universiteit Amsterdam
    jfdsmit@few.vu.nl | http://www.few.vu.nl/~jfdsmit

  3. Re: Broken sed on 3.1.2a?

    > Not really, sed on Solaris does not print "1" on stdout either, but "123
    > 45 6". I suppose that is the output you get on Minix as well, right? Try
    > placing the caret ('^') before the parentheses instead of inside them, it
    > helps on Solaris.


    Your suggestion worked nicely! I'm not sure why Minix's sed doesn't
    accept it correctly when the carat is inside the parentheses, but I'll
    just go with it.

    Thanks again!


+ Reply to Thread