From owner-freebsd-questions@FreeBSD.ORG Thu Apr 12 09:04:50 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2AD7916A400 for ; Thu, 12 Apr 2007 09:04:50 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout7.cac.washington.edu (mxout7.cac.washington.edu [140.142.32.178]) by mx1.freebsd.org (Postfix) with ESMTP id 091FD13C457 for ; Thu, 12 Apr 2007 09:04:50 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.33.9] (may be forged)) by mxout7.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW07.03) with ESMTP id l3C94l61030458 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 Apr 2007 02:04:47 -0700 X-Auth-Received: from [192.168.10.45] (c-24-7-142-221.hsd1.ca.comcast.net [24.7.142.221]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW07.03) with ESMTP id l3C94kE9002971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 12 Apr 2007 02:04:47 -0700 Message-ID: <461DF63A.3010507@u.washington.edu> Date: Thu, 12 Apr 2007 02:04:58 -0700 From: Garrett Cooper User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <33E0F3313625E543ACCC41AE2DFD5EF5024280@BB06.bolsabilbao.local> In-Reply-To: <33E0F3313625E543ACCC41AE2DFD5EF5024280@BB06.bolsabilbao.local> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 5.3.0.289146, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.4.12.15334 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __USER_AGENT 0' Subject: Re: Shell scripting: Absolute path name of a file given as parameter 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: Thu, 12 Apr 2007 09:04:50 -0000 Aitor San Juan wrote: > Hi List, > > Just a simple question. > > I have developed a shell script that, among other things, shows the filename > that was specified as a parameter. > > However, when I invoke the script and the file is located in the current working > directory, it just shows: ./my_input_filename > > I'd like the script to show the full path name of the input file. I wonder > whether there is or not an equivalent to %~f1 (Windows Batch file programming). > This parameter extension expands parameter %1 ($1 in shell scripting jargon) to a > Fully qualified path name. > > Any hint would be highly appreciated. > > Thanks in advance. > > Aitor. You could always do it relative to the current working path, i.e. "`pwd`/./my_input_filename". There's another way to do this by determining the absolute path of the shell script, but that was a bit more complicated and I don't remember where the documentation for that is right now.. -Garrett