On Fri, 2008-02-29 at 12:16 -0600, Don Sparish wrote:
> Is Solaris Ass Backward or what. 
> 
> I can get an exact string match in AIX, Linux, HPUX but not in
> SlowLaris. 

Please define "exact string match".  I thought that was what grep
usually does...  Do you want to match an entire line?  A substring
bounded by some sort of delimeter (a colon, comma, or similar)?

To match a whole line, you'd want 

        grep '^string$'

'^' and '%' match the beginning and end of the line.  No need for '-E'
or anything.  If you're having trouble with 'grep -E', try 'egrep'
instead.

Of course, if you know the variable you're looking for, it'd be cheaper
to just do a simple test:

    [ "$VAR" == "string" ] && echo true

If you're wanting to match a substring in a variable such as $PATH which
uses the ':' delimeter, you can do something like this:

        echo $PATH | egrep '(^|:)/bin(:|$)'

If you're searching through the whole list of environment variables by
just grepping the output of 'set' or something, replace the '^' with
'='.

As for Solaris annoyances in general...

I agree with Mike Miller -- if your /usr/xpg4/bin/grep is not accepting
'-E', '-x', or '-w' at all, then it's a broken binary.  You might check
if someone made it a symlink pointing somewhere else.  If you've been
relying on your $PATH, make sure you don't have an alias pointing at a
particular version.

I recently discovered Solaris's standards(5) man page and some other
info about the various binary paths on that operating system (er, I mean
"operating environment" ... Pardon me! *cough*).  It basically says that
the programs in /usr/bin are intentionally old and crappy.  They're
historic pre-POSIX,1(!) Solaris programs.  Some searching around
revealed the actual purpose behind a number of the different binary
directories on Solaris these days.  You really want them in your $PATH
ahead of /usr/bin.

Paraphrasing from some of my tcsh login scripts on Sun hosts (bash
version left as an exercise for the reader, as are possible other paths
in /opt or /usr/local, the various sbin paths, GNOME, and any other
random crap that might be on your not-so-friendly neighborhood Solaris
cluster):

        set tmp = ( $home/bin /usr/local/bin ) # Locally-built stuf
        set tmp = ( $tmp /opt/sfw/bin )  # admin-installed SunFreeware
        set tmp = ( $tmp /usr/sfw/bin )  # Sun-supplied SunFreeware (older)
        set tmp = ( $tmp /usr/ucb )      # (UC Berkeley) BSD-like commands
        set tmp = ( $tmp /usr/xpg6/bin ) # SUSv3 POSIX standard, aka XPG6
        set tmp = ( $tmp /usr/xpg4/bin ) # XPG4 standard
        set tmp = ( $tmp /usr/bin )      # Sun binaries, often obsolete vs above
        set tmp = ( $tmp /usr/ccs/bin )  # C Compiler (cc) Stuff?
        set tmp = ( $tmp /usr/openwin/bin ) # X Window System
        set tmp = ( $tmp /bin ) # a symlink to /usr/bin on Solaris, but just in case
                                # this script ever lands on other OSes..
        
        # clear the default path, probably ( /usr/bin /bin /usr/sbin /sbin )
        set path = ( )
        foreach p ( $tmp )
            if ( -d $p ) set path = ( $path $p )
        end
        unset tmp

Note that I put /usr/ucb ahead of some other directories.  While Linux
has borrowed a lot from Solaris, it has also taken quite a lot from BSD.
Being a Linux guy, the BSD-style commands in /usr/ucb tend to make me
happier (yay for 'ps ax'!), but that may just be personal preference.

Still, most of those directories only have a relative handful of
binaries.  Unless you've got a GNU grep in /usr/local/bin or one of the
SunFreeware directories, it'll still fall through to the XPG4 version.

-- 
Mike Hicks <hick0088 at tc.umn.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20080229/f468447e/attachment-0001.pgp