OT: How to match a substring?
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
Reply to: