From owner-freebsd-questions Sun Jul 2 14:59: 7 2000 Delivered-To: freebsd-questions@freebsd.org Received: from manatee.mammalia.org (manatee.mammalia.org [216.231.50.6]) by hub.freebsd.org (Postfix) with ESMTP id 4082337B703 for ; Sun, 2 Jul 2000 14:59:04 -0700 (PDT) (envelope-from rjoseph@mammalia.org) Received: by manatee.mammalia.org (Postfix, from userid 1000) id 89F8211CE07; Sun, 2 Jul 2000 14:59:03 -0700 (PDT) Date: Sun, 2 Jul 2000 14:59:03 -0700 From: R Joseph Wright To: Jon Hamilton Cc: freebsd-questions@FreeBSD.org Subject: Re: making shell script run in its own directory Message-ID: <20000702145903.A66917@manatee.mammalia.org> References: <20000702130901.A66305@manatee.mammalia.org> <20000702211344.38B1216F@woodstock.monkey.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20000702211344.38B1216F@woodstock.monkey.net>; from hamilton@pobox.com on Sun, Jul 02, 2000 at 04:13:44PM -0500 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Jul 02, 2000 at 04:13:44PM -0500, Jon Hamilton wrote: > > In message <20000702130901.A66305@manatee.mammalia.org>, R Joseph Wright wrote: > } How do I make a shell script run in the directory where it resides rather tha > } n > } the directory where it was called from? > > Before you do anything interesting in the script, add a line like: > > cd $(dirname $0) > > Though generally I consider this kind of thing bad practice. It works! Can yourself on that last point? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message