[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: How to match a substring?



Kent,

  Just use `uname -s`.  This will report back "Linux" on Linux and
  "SunOS" on Solaris.

Steve

On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote:
> This oughtta be simple for your scripters out there . . .
> 
> I need to run a test in a .bashrc startup script to see whether the 
> machine the user is logging onto is a Solaris or a Linux box (the /home 
> directory is shared between the two, and paths need to be modified 
> according to which OS is being logged into).
> 
> Something like this:
> 
> if {the first word of "uname -a" is Linux}
> then echo "You're logging into Linux"
> else
> echo "You're logging into something else, probably Solaris"
> fi
> 
> My problem is that I don't know how to match for the first word of 
> "uname -a". I've tried things like:
> 
> if [ `uname -a`:0:5} = "Linux" ]
> 
> and
> 
> if {awk '{ print $1 }' < `uname -a` = "Linux" ]
> 
> and etc, but I can't seem to get this figured out.
> 
> Any help would be appreciated.
> 
> Thanks!
> 
> -- 
> Kent
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact 
> listmaster@lists.debian.org
> 

=============================================================
Steve Mayer				Oracle Corporation
Project Lead				1211 SW 5th Ave.
Portland Development Center 		Suite 900
Stephen.Mayer@oracle.com		Portland, OR 97204 
Phone:  503-525-3127
=============================================================



Reply to: