Re: OT: How to match a substring?

2004-01-15 Thread Osamu Aoki
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 [

OT: How to match a substring?

2004-01-14 Thread Kent West
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

Re: OT: How to match a substring?

2004-01-14 Thread Steve Mayer
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

Re: OT: How to match a substring?

2004-01-14 Thread Colin Watson
On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote: 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

Re: OT: How to match a substring?

2004-01-14 Thread Jan Minar
On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote: This oughtta be simple for your scripters out there . . . Hi, Kent You have to understand the difference between a pipe ``|'', and a command substitution ``$(foo)'' (backticks can be used instead of $(), when nesting isn't needed). The

Re: OT: How to match a substring?

2004-01-14 Thread Gregory Seidman
On Wed, Jan 14, 2004 at 06:14:45PM +, Colin Watson wrote: } On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote: } 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

Re: OT: How to match a substring?

2004-01-14 Thread Kent West
Steve Mayer wrote: On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote: 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

Re: OT: How to match a substring?

2004-01-14 Thread Kent West
Colin Watson wrote: On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote: I need to run a test in a .bashrc startup script . . . if {the first word of uname -a is Linux} Why not just use 'uname', which prints Linux on Linux and SunOS on Solaris? That solves my problem! Thanks!

Re: OT: How to match a substring?

2004-01-14 Thread Kent West
Gregory Seidman wrote: } On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote: } I need to run a test in a .bashrc startup script } } if {the first word of uname -a is Linux} } if expr `uname -a` : 'Linux ' /dev/null Thanks! -- Kent -- To UNSUBSCRIBE, email to [EMAIL PROTECTED]

Re: OT: How to match a substring?

2004-01-14 Thread Kent West
Jan Minar wrote: On Wed, Jan 14, 2004 at 11:59:12AM -0600, Kent West wrote: This oughtta be simple for your scripters out there . . . The script follows: #!/bin/sh case $(uname -a | awk '{print $1}') in Linux) echo Hi, I'm Linus Torvalds I pronounce Linux as Linux. ;; Solaris)

Re: OT: How to match a substring?

2004-01-14 Thread David Z Maze
Kent West [EMAIL PROTECTED] 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 ;; *)

Re: OT: How to match a substring?

2004-01-14 Thread Jan Minar
On Wed, Jan 14, 2004 at 05:43:18PM -0500, David Z Maze wrote: case `uname -a` in Linux*) O-oh, I completely missed the possibility not to use awk friends... Which has the minor advantage of only using shell primitives, aside from the call out to uname itself. Heh, yet I have something