I try to use a sed line with a + on a Solaris machine and on a Linux machine.

on Solaris sed does not remove the strings until the first number like I want:

   solaris:/ ROOT > echo "Release............5.3.7.1-12"  | sed 's/[^0-9]\+//'

   Release............5.3.7.1-12

on Linux I get the expected results:

  linux tmp]# echo "Linux Release............5.3.7.1-12"  | sed 's/[^0-9]\+//'

  5.3.7.1-12
  • Why is this sed syntax not working on Solaris?

  • What do I need to change in the syntax in order for it to run on Solaris?

link|improve this question

50% accept rate
feedback

1 Answer

up vote 0 down vote accepted

Normally, escaping the + character (\+) results in a literal +, not a modifier. This is not the case with sed on Ubuntu 10.04, but it might not be on Solaris.

My best guess it that this is implementation-specific, so sed 's/[^0-9]\+//' might work.

You could also try sed -r 's/[^0-9]\+//' (where -r means extended regular expressions). It works on Ubuntu 10.04.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.