Re: OT: How to match a substring?
On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote:
> if {the first word of "uname -a" is Linux}
Hi, Colin and others gave "correct" answers :-)
Just for the heck, I have no "awk", no "sed", no shell pattern match to
do this.
----
#!/bin/sh
get_first () {
BUFFER=$1
}
get_first `uname -a`
if [ $BUFFER = "Linux" ] ; then
echo Linux is the first word
fi
-----
I call this a stupid shell trick with function. You can do 2nd and
third word match easily with this in system with only POSIX shell.
Reply to: