Date: Thu, 27 Mar 1997 09:41:00 -0800 (PST) From: Doug White <dwhite@resnet.uoregon.edu> To: John Clark <email@john.net> Cc: questions@FreeBSD.ORG Subject: Re: BASH -> passing cmd line params Message-ID: <Pine.BSI.3.95.970327093833.23103D-100000@resnet.uoregon.edu> In-Reply-To: <3.0.1.32.19970325173551.00aa5260@199.3.74.250>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 25 Mar 1997, John Clark wrote: > Hello, I am having trouble passing a variable with a space in it as a > single parameter. Is there a way to do this? > > > #!/bin/sh > > PARAM1="hello world" > PARAM2="foo" > PARAM3="bar" > > mycommand $PARAM1 $PARAM2 $PARAM3 > > > The output of the above script shows 4 command line variables: 1=hello, > 2=world, 3=foo, 4=bar > > I would like: 1=hello world, 2=foo, 3=bar > > Any help would be appreciated. The output is correct. Remember that the space is the separator between options. If you want your program to consider "hello world" as one option, enclose itin quotations: mycommand "$PARAM1" $PARAM2 $PARAM3 Hope this helps. Doug White | University of Oregon Internet: dwhite@resnet.uoregon.edu | Residence Networking Assistant http://gladstone.uoregon.edu/~dwhite | Computer Science Major
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSI.3.95.970327093833.23103D-100000>