From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 29 23:24:55 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2F4B616A420; Tue, 29 Nov 2005 23:24:55 +0000 (GMT) (envelope-from marcogi.lists@email.it) Received: from vsmtp21alice.tin.it (vsmtp21.tin.it [212.216.176.109]) by mx1.FreeBSD.org (Postfix) with ESMTP id 504A143D9C; Tue, 29 Nov 2005 23:24:41 +0000 (GMT) (envelope-from marcogi.lists@email.it) Received: from flyby (82.52.159.86) by vsmtp21alice.tin.it (7.2.060.1) id 437B155F0020D135; Wed, 30 Nov 2005 00:24:39 +0100 Received: from marco by flyby with local (Exim 3.36 #1 (Debian)) id 1EhEpz-00076C-00; Wed, 30 Nov 2005 00:24:39 +0100 Date: Wed, 30 Nov 2005 00:24:39 +0100 From: Marco Gigante To: Jayesh Jayan Message-ID: <20051129232439.GA26903@linuxhost> Mail-Followup-To: Jayesh Jayan , freebsd-questions@freebsd.org, freebsd-hackers@freebsd.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11 Cc: freebsd-hackers@freebsd.org, freebsd-questions@freebsd.org Subject: Re: Bash scripting -- Usage of arrays X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2005 23:24:55 -0000 On Wed, Nov 30, 2005 at 02:39:15AM +0530, Jayesh Jayan wrote: > 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 ")") You should use: bash array.sh On FreeBSD sh != bash $ ls -l `which sh` -r-xr-xr-x 1 root wheel 763316 Sep 3 08:37 /bin/sh $ ls -l `which bash` -rwxr-xr-x 2 root wheel 471136 Jun 12 01:13 /usr/local/bin/bash Cheers -- Marco Gigante