Re: Can $1 be set in a script?



On Thu, 30 Mar 2006 13:44:57 -0900, Floyd L. Davidson
<floyd@xxxxxxxxxx> wrote:
larryalk <nobody@xxxxxxxxxxx> wrote:

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

something=${1:-"default string"}


--
My doctorate's in Literature, but it seems like a pretty good pulse to me.
.



Relevant Pages

  • Re: Can $1 be set in a script?
    ... To be clearer, assuming a script called with or without a $1 ... how can I can assign the (possibly non-existant) $1 to something? ... Matter of opinion... ...
    (comp.os.linux.x)
  • Re: rewriten repost a little ot
    ... "Argus" schreef in bericht ... going try and make it a little clearer this time ... DHCP and orther TCP IP services of the server and other network ... Placing a batchfile calling the script from ...
    (microsoft.public.cert.exam.mcse)
  • Re: a stupid question on word.application
    ... determining their value in the application and providing it in a CONST ... statement in the script. ... ok all is clearer Thanks. ... Tom Lavedas ...
    (microsoft.public.scripting.vbscript)
  • Gmirror on boot
    ... Believe it or not, I've rtfmed and googled, but am no clearer. ... run "gmirror load" on startup followed by a drive mounting. ... the lines or do I have to create a script, and if so, where do I have to ...
    (comp.unix.bsd.freebsd.misc)
  • Re: Date time in awk
    ... > Chris F.A. Johnson wrote: ... > Or just slightly briefer: ... > thought of so it seems clearer to me personally. ... I, too, thought this sounded like homework, and posted a script ...
    (comp.unix.shell)