From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 29 21:34:57 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 9CDE916A41F for ; Tue, 29 Nov 2005 21:34:57 +0000 (GMT) (envelope-from fcash-ml@sd73.bc.ca) Received: from smtp.sd73.bc.ca (smtp.sd73.bc.ca [142.24.13.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0B08543D8C for ; Tue, 29 Nov 2005 21:34:27 +0000 (GMT) (envelope-from fcash-ml@sd73.bc.ca) Received: from localhost (localhost [127.0.0.1]) by localhost.sd73.bc.ca (Postfix) with ESMTP id AAA0D8A0106 for ; Tue, 29 Nov 2005 13:35:26 -0800 (PST) Received: from smtp.sd73.bc.ca ([127.0.0.1]) by localhost (mailtest.sd73.bc.ca [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 42667-01-85 for ; Tue, 29 Nov 2005 13:35:25 -0800 (PST) Received: from [192.168.0.157] (unknown [192.168.0.157]) by smtp.sd73.bc.ca (Postfix) with ESMTP id 45A038A0102 for ; Tue, 29 Nov 2005 13:35:25 -0800 (PST) From: Freddie Cash Organization: School District 73 To: freebsd-hackers@freebsd.org Date: Tue, 29 Nov 2005 13:34:12 -0800 User-Agent: KMail/1.8.2 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200511291334.13467.fcash-ml@sd73.bc.ca> X-Virus-Scanned: by amavisd-new using ClamAV at sd73.bc.ca X-Mailman-Approved-At: Tue, 29 Nov 2005 21:44:29 +0000 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 21:34:57 -0000 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