From owner-freebsd-questions@FreeBSD.ORG Fri Nov 16 04:43:45 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 F233116A468 for ; Fri, 16 Nov 2007 04:43:45 +0000 (UTC) (envelope-from girishvenkatachalam@gmail.com) Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.184]) by mx1.freebsd.org (Postfix) with ESMTP id C888413C44B for ; Fri, 16 Nov 2007 04:43:45 +0000 (UTC) (envelope-from girishvenkatachalam@gmail.com) Received: by rv-out-0910.google.com with SMTP id l15so571718rvb for ; Thu, 15 Nov 2007 20:43:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:from:to:subject:message-id:reply-to:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; bh=5gAZqUXVSXWYuYI5j3413ARNWCr20V8OAOGk0wWVcqQ=; b=F0Phz1ihopW8OKzCbYjABZudIEz1TullvzlQ3p2J3QuFHhAOpu61XCO+e05ZsHb44IKXRpRpeSHvwsBJ7fwVmxz1YZb55QHMwCNBwhLDGuK4SzXp8sFNS9xAI03nHPoRKxhqkThGN3L9tPIPfvBCzBhMm/koNlll1KVz/NhJyw8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:subject:message-id:reply-to:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=Ozs6mn0DAYC4qugggyyjuedNqAJZO9KGK2NKeHpOAIr96ZMC4qNaQsi5B9ZyqPcpxTKfzHET4EwG1oghBegkJCUuzqsR8RBi/NosqTs+pdqxS+b22A5Z+qPevHu3fDEjmPkq2RbP+zpOJiWHUTnCRu6IDo2y5kblVBhRlPEZmIA= Received: by 10.141.153.16 with SMTP id f16mr420086rvo.1195188217514; Thu, 15 Nov 2007 20:43:37 -0800 (PST) Received: from saraswathy.susmita.org ( [59.92.57.146]) by mx.google.com with ESMTPS id c36sm4278978rvf.2007.11.15.20.43.35 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Nov 2007 20:43:37 -0800 (PST) Received: by saraswathy.susmita.org (Postfix, from userid 1002) id 99DAB143E7; Fri, 16 Nov 2007 10:13:31 +0530 (IST) Date: Fri, 16 Nov 2007 10:13:31 +0530 From: Girish Venkatachalam To: freebsd-questions@freebsd.org Message-ID: <20071116044331.GA21372@saraswathy.susmita.org> Mail-Followup-To: freebsd-questions@freebsd.org 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> User-Agent: Mutt/1.5.12-2006-07-14 Subject: Re: bash and strings X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: girishvenkatachalam@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Nov 2007 04:43:46 -0000 On 03:43:24 Nov 16, 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. > > Any suggestions would be greatly appreciated. There is always more than one way to skin a cat. :) Perhaps you will like mine. DIR=`dirname $path` FILE=`basename $path` /bin/mkdir -p $DIR cd touch $FILE You can put this in a loop with path as loop variable. Best of luck! regards, Girish