From owner-freebsd-questions@FreeBSD.ORG Fri Nov 16 13:34:35 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 4E5BA16A418 for ; Fri, 16 Nov 2007 13:34:35 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 9F05C13C47E for ; Fri, 16 Nov 2007 13:34:33 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (vader.bytemobile-rio.ondsl.gr [83.235.57.37]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-9) with ESMTP id lAGDXkhm023700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 16 Nov 2007 15:34:07 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id lAGDXem9002392; Fri, 16 Nov 2007 15:33:40 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id lAGDXeQt002391; Fri, 16 Nov 2007 15:33:40 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 16 Nov 2007 15:33:39 +0200 From: Giorgos Keramidas To: jhall@vandaliamo.net Message-ID: <20071116133339.GA2312@kobe.laptop> References: <52275.12.170.206.13.1195184604.squirrel@admintool.trueband.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52275.12.170.206.13.1195184604.squirrel@admintool.trueband.net> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.996, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.40, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: freebsd-questions@freebsd.org Subject: Re: bash and strings 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: Fri, 16 Nov 2007 13:34:35 -0000 On 2007-11-16 03:43, jhall@vandaliamo.net wrote: > Everyone, > > I'm sure this is easy, and I am making it harder than it is. > > I am being supplied a list of files, and need to create the files and > directories to hold them, but I cannot figure out how to take the string > apart. > > For example, I am given > > /usr/local/scripts/firewall.sh > > I need to create the /usr/local/scripts directory and then create > firewall.sh. See the `dirname' and `basename' commands: $ dirname "/usr/local/scripts/firewall.sh" /usr/local/scripts $ $ basename "/usr/local/scripts/firewall.sh" firewall.sh $ Be careful about properly quoting the filenames though (note how the first invocation of `dirname' fails below, and try to understand why it fails): $ testname='foo bar baz' $ dirname $testname usage: dirname string $ dirname "${testname}" . $