Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I run the following sed syntax on Solaris machine and on Linux machine

on Linux machine sed do the JOB its remove all characters until the first number.

but why this sed syntax not work on Solaris ?

What I need to change in the sed syntax in order run it on Solaris?

on solaris (sed - not remove the strings until the first number?)

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

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

on linux ( I get good results )

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

  5.3.7.1-12
share|improve this question
1  
Take a look at sunfreeware.com, you can download the GNU version of utilities from there as packages. –  Iain Jan 10 '12 at 16:58
    
possible duplicate of How do I use sed or awk to remove text? –  MadHatter Jan 10 '12 at 17:04

1 Answer 1

up vote 4 down vote accepted

Solaris generally doesn't have the GNU version of anything by default. This means that the options and arguments you supply will often have to be different to get the same behaviour out of utilities like sed.

Sometimes it will not be possible to get the same behaviour at all, for instance, sed -i won't work on Solaris unless you have installed the GNU version of sed.

From memory, the sed on Solaris supports the "basic" set of regular expressions and this doesn't include the + modifier. You can simulate a + like this:

sed 's/[^0-9][^0-9]*//'

Or you can just use a * for this case:

sed 's/[^0-9]*//'

Solaris usually also has the BSD versions of these utilities installed under /usr/ucb. they are often very similar but occasionally have important differences, such as with ps.

share|improve this answer

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.