Date: Fri, 16 Nov 2007 15:33:39 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: jhall@vandaliamo.net Cc: freebsd-questions@freebsd.org Subject: Re: bash and strings Message-ID: <20071116133339.GA2312@kobe.laptop> In-Reply-To: <52275.12.170.206.13.1195184604.squirrel@admintool.trueband.net> References: <52275.12.170.206.13.1195184604.squirrel@admintool.trueband.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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}" . $
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071116133339.GA2312>