Re: Can $1 be set in a script?
- From: Bill Marcum <bmarcum@xxxxxxxxx>
- Date: Fri, 31 Mar 2006 01:35:57 -0500
On Thu, 30 Mar 2006 13:44:57 -0900, Floyd L. Davidson
<floyd@xxxxxxxxxx> wrote:
larryalk <nobody@xxxxxxxxxxx> wrote:something=${1:-"default string"}
To be clearer, assuming a script called with or without a $1
how can I can assign the (possibly non-existant) $1 to something?
Instead of
something=${1}
Do this,
if [ -z "${1}" ]
then
something="default string"
else
something="${1}"
fi
--
My doctorate's in Literature, but it seems like a pretty good pulse to me.
.
- Follow-Ups:
- Re: Can $1 be set in a script?
- From: larryalk
- Re: Can $1 be set in a script?
- References:
- Can $1 be set in a script?
- From: larryalk
- Re: Can $1 be set in a script?
- From: Chris F.A. Johnson
- Re: Can $1 be set in a script?
- From: larryalk
- Re: Can $1 be set in a script?
- From: Floyd L. Davidson
- Can $1 be set in a script?
- Prev by Date: Re: Can $1 be set in a script?
- Next by Date: Re: Can $1 be set in a script?
- Previous by thread: Re: Can $1 be set in a script?
- Next by thread: Re: Can $1 be set in a script?
- Index(es):
Relevant Pages
|