Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: "Lee A. Newcomb" <lan@zk3.dec.com>
Subject: Re: korn shell
Date: 2000/11/14	[thread overview]
Message-ID: <3A11CB64.C6BAC88A@zk3.dec.com> (raw)
In-Reply-To: 3A1162EC.6DBA7560@gnsconsulting.com.au

Your explanation is right as to what it does, but slightly
wrong in the description:
    ${2:-10}
means if $2 is not null, use its value; otherwise use '10'
(not '-10').  If -10 was used, 'sort -nr $1 | head -${2:-10}'
would be expanded to 'sort -nr $1 | head --10}' with an error
msg. like 'Badly formed number' displayed to stderr.

For more detail, do a 'man ksh' and look at the section
'Conditional Substitution' section, which describes the use
of ${var:-str}, ${var:=str},  ${var:?str},  ${var:+str}, ...
E.g.:

  ${ variable:-string }
      If the variable is set and is not null, substitute the value of
      variable in place of this expression.  Otherwise, replace this
      expression with the value of string.

Learning the Korn Shell is a great book.  But make sure to check
your system's manpage for specific syntax def's.

Enjoy ksh,
-- lan



      reply	other threads:[~2000-11-14  5:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-14  5:00 korn shell tru64man
2000-11-14  5:00 ` Robert Mulley
2000-11-14  5:00   ` Lee A. Newcomb [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox