Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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