[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a special variable for the directory where the script is in
From: |
Chris F.A. Johnson |
Subject: |
Re: Is there a special variable for the directory where the script is in? |
Date: |
Thu, 11 Feb 2010 18:23:03 -0500 (EST) |
User-agent: |
Alpine 2.00 (LMD 1167 2008-08-23) |
On Fri, 12 Feb 2010, Peng Yu wrote:
> $0 gives the file name of the script. I could use several shell
> command to get the directory where the script is in. But I'm wondering
> if there is an easy-to-use variable that refers to the directory where
> the script is in?
$0 normally gives the full path to the file, so: "${0%/*}"
--
Chris F.A. Johnson <http://cfajohnson.com>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)