From owner-freebsd-questions@FreeBSD.ORG Tue Nov 20 19:10:31 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80F3216A41B for ; Tue, 20 Nov 2007 19:10:31 +0000 (UTC) (envelope-from pigskin_referee@yahoo.com) Received: from web34409.mail.mud.yahoo.com (web34409.mail.mud.yahoo.com [66.163.178.158]) by mx1.freebsd.org (Postfix) with SMTP id 4591013C48A for ; Tue, 20 Nov 2007 19:10:31 +0000 (UTC) (envelope-from pigskin_referee@yahoo.com) Received: (qmail 63821 invoked by uid 60001); 20 Nov 2007 19:10:29 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=6jK7R+AIGDu+6CLRpCuocaZ1LRHOeEQ1+jgldL6lT/8naNZpAsOzLRhi72LhdxoEwDnY1AKnCJewDGBvfE94v8QHKoI77x1tr1rimWwjJmRlM1zp7uW2TlaOL0qeWwRNK3/sc1RgFMps5CE1P2Akg5q+PKQQyqpnelH/OQDlRq8=; X-YMail-OSG: F.4eUpQVM1l7H3UJSqCDNyKulN5KLRC4zZJaFDJ.jTFjVmz6R3JI7AIl8WRe2KMeff1H5o2DS17DV197ZkWKF3LhlL6_3b5nis4nENaHdcgTF668OBw- Received: from [67.189.206.211] by web34409.mail.mud.yahoo.com via HTTP; Tue, 20 Nov 2007 11:10:29 PST X-Mailer: YahooMailRC/818.27 YahooMailWebService/0.7.157 Date: Tue, 20 Nov 2007 11:10:29 -0800 (PST) From: White Hat To: FreeBSD Users Questions MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <542256.58741.qm@web34409.mail.mud.yahoo.com> Subject: Storing variable in Bash X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2007 19:10:31 -0000 I am attempting to write a script that will work on files stored in an array. The function is supposed to strip the files extension and then store the name of the file as a variable. This is what I have so far. #!/usr/local/bin/bash declare -a fname declare -i count declare -i limit fname=( `ls *.sh | tr '\n' ' '` ) count=${#fname[*]} limit=0 while [ ${limit} -lt ${count} ]; do echo ${fname[$limit]} | sed -e ``/.sh/s///'' # do something here limit=$((limit+1)) done What I want to do is store the file in a variable. I have tried this: F_Name=echo ${fname[$limit]} | sed -e ``/.sh/s///'' As well as: F_Name=( `echo ${fname[$limit]} | sed -e ``/.sh/s///''` ) along with several different variants of it, but without success. I continually receive an error message. Due to a particular situation, I cannot use 'basename' to accomplish this task. Is there anyway that this can be done? Thanks! -- White Hat pigskin_referee@yahoo.com ____________________________________________________________________________________ Get easy, one-click access to your favorites. Make Yahoo! your homepage. http://www.yahoo.com/r/hs