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

Re: OT: How to match a substring?



Kent West <westk@acu.edu> writes:

> 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

For yet another approach:

case `uname -a` in
  Linux*)
    echo "You're logging into Linux"
    ;;
  *)
    echo "You're logging into something else, probably Solaris"
    ;;
esac

Which has the minor advantage of only using shell primitives, aside
from the call out to uname itself.

-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell



Reply to: