Re: Bash scripting -- Usage of arrays

From: Freddie Cash (fcash-ml_at_sd73.bc.ca)
Date: 11/29/05

  • Next message: Jayesh Jayan: "Re: Bash scripting -- Usage of arrays"
    To: freebsd-hackers@freebsd.org
    Date: Tue, 29 Nov 2005 13:34:12 -0800
    
    

    On November 29, 2005 01:09 pm, Jayesh Jayan wrote:
    > 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

    /bin/sh on Linux is actually /bin/bash.

    > 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 ")")

    /bin/sh on FreeBSD is /bin/sh, the original Bourne shell. It doesn't use
    that syntax

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

    Install the bash1, bash2, or bash port and use /usr/local/bin/bash to
    execute the script.

    Works correctly on my 5.4 and 6.0 systems using the bash-emulation in zsh.

    -- 
    Freddie Cash, LPIC-1 CCNT CCLP      Helpdesk / Network Support Tech.
    School District 73                  (250) 377-HELP [377-4357]
    fcash-ml@sd73.bc.ca
    _______________________________________________
    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: Jayesh Jayan: "Re: Bash scripting -- Usage of arrays"

    Relevant Pages

    • Re: Bash scripting -- Usage of arrays
      ... > Below is a sample script which I used. ... > Below is the out put from the FreeBSD server using the same code. ... > Please guide me on how to use arrays on freebsd too. ... You can either install bash from ports, or you can write your scripts in sh ...
      (freebsd-hackers)
    • Re: Bash scripting -- Usage of arrays
      ... > Below is a sample script which I used. ... > Below is the out put from the FreeBSD server using the same code. ... > Please guide me on how to use arrays on freebsd too. ... You can either install bash from ports, or you can write your scripts in sh ...
      (freebsd-questions)
    • Re: Bash scripting -- Usage of arrays
      ... > Below is a sample script which I used. ... > Below is the out put from the FreeBSD server using the same code. ... > Please guide me on how to use arrays on freebsd too. ... Bash is in /usr/local/bin. ...
      (freebsd-questions)
    • Re: trouble with a script
      ... Your snippet of code doesn't look like sh on FreeBSD. ... Basically, I want my script to prompt me for two inputs, then append to ... The user input would be "domain.com", ... is how we set up a client's site on our servers. ...
      (comp.unix.shell)
    • Re: trouble with a script
      ... Your snippet of code doesn't look like sh on FreeBSD. ... Basically, I want my script to prompt me for two inputs, then append to ... The user input would be "domain.com", ... is how we set up a client's site on our servers. ...
      (comp.unix.shell)