Bash scripting -- Usage of arrays

From: Jayesh Jayan (jayesh.freebsdlist_at_gmail.com)
Date: 11/29/05

  • Next message: John-Mark Gurney: "Re: Bash scripting -- Usage of arrays"
    Date: Wed, 30 Nov 2005 02:39:15 +0530
    To: freebsd-questions@freebsd.org, freebsd-hackers@freebsd.org
    
    

    Hi,

    Today I was trying to script using arrays in FreeBSD 5.4 but it doesn't
    work.

    Below is a sample script which I used.

    ******************************************************

    #!/bin/bash

    array=( zero one two three four);
    echo "Elements in array0: ${array[@]}"

    ******************************************************

    It works fine on RedHat server.

    Below is the output.

    # sh array.sh
    Elements in array0: zero one two three four

    Below is the out put from the FreeBSD server using the same code.

    -bash-2.05b# sh aa.sh
    aa.sh: 3: Syntax error: word unexpected (expecting ")")

    Please guide me on how to use arrays on freebsd too.

    --
    Jayesh Jayan
    "The box said "Requires Windows 95, NT, or better", so I installed Linux."
    Visit my homepage @ http://www.jayeshjayan.com
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    

  • Next message: John-Mark Gurney: "Re: Bash scripting -- Usage of arrays"

    Relevant Pages

    • Bash scripting -- Usage of arrays
      ... Below is a sample script which I used. ... zero one two three four ... Below is the out put from the FreeBSD server using the same code. ... Please guide me on how to use arrays on freebsd too. ...
      (freebsd-questions)
    • Re: Unpack When? Part II
      ... the server date only. ... sparse arrays which allows cross-referencing ... Null and zero are almost always the same so don't ... get the .thisiscool property value by ...
      (comp.databases.pick)
    • Re: Setting based 1 Arrays
      ... Generally I don't have documentation from last century on my PC so no I have no read it. ... some other areas of vb6 are most definately 1 based. ... Which areas are 1 based and which are zero based appears to be random. ... I probably would not have used it in our WCVB.BAS header interface file because it has the explicit lower and upper range defined for the arrays field we have. ...
      (microsoft.public.dotnet.languages.vb)
    • Re: "Ugly" declaration of high rank automatic arrays
      ... Not unless assumed-shape arrays fit your needs. ... several arrays you can use 'specification variables' (I just now made ... CHARACTER variable has zero length at ... and both compilers are handling this case OK. ...
      (comp.lang.fortran)
    • Re: should every thing be zero indexed?
      ... I just don't know why a programmer would want his 4th ... As for zero based indexing, i think that's fine for arrays ... which you can use an iterator in a loop, ...
      (comp.programming)