Re: Another question

From: Stephane CHAZELAS (stephane_chazelas_at_yahoo.fr)
Date: 04/25/03


Date: 25 Apr 2003 10:53:45 GMT

Good guy wrote:
[...]
> How can I detect if counter is bigger than 5? ( if ( test $counter > 5 ) is
> not correct, isn't it?

POSIX way is

if [ "$counter" -gt 5 ]; then ...

bash/ksh/zsh way is
if (( counter > 5 )); then ...

> How can i show the results in a printf ? (my implementation gives me a [1]:
> Invalid number

Same as your other error: ${c[1]} instead of $c[1]

How is it that you need arrays and arithmetic in a script. My
guess is that you'd need a programming language here instead of
a shell.

-- 
Stéphane


Relevant Pages

  • Re: POSIX shell: no arrays? no RANDOM?
    ... POSIX doesn't mention arrays. ... Nothing in 2.5.3 ("Shell ... POSIX conformant shells you have to restrict to the subset of features ...
    (comp.unix.shell)
  • Re: =?utf-8?Q?Portabilit=C3=A4t?_(was:_Text_splitten)?=
    ... man es braucht (traditionell, POSIX, bestimmes OS, bash-3, etc.). ... Zu einem gewissen Grad hat das sogar was sportliches; Usenet eben... ... Am den dominierenden Systemen gemessen erscheint sowas ... vorhandene /bin/sh kann keine Arrays? ...
    (de.comp.os.unix.shell)
  • Re: VBA validation & error reporting
    ... (some of your declarations don't seem to be corresponding to this sub, ... Msgbox "Check the value in cell & MyCell", ... used arrays yet so i'm not sure how they differ from a range, ... invalid value is encountered. ...
    (microsoft.public.excel.programming)
  • POSIX shell: no arrays? no RANDOM?
    ... I'm trying to write some shell code that will run on any POSIX- ... POSIX doesn't mention arrays. ... The limits as I've discovered ...
    (comp.unix.shell)
  • Re: How Can I Cast DotNet Variables into a byte array?
    ... The cast to byteis not invalid because arrays are zero-based. ... addition to the fact that there is no cast from uint to byte). ...
    (microsoft.public.dotnet.languages.csharp)