Date: Thu, 12 Apr 2007 02:04:58 -0700 From: Garrett Cooper <youshi10@u.washington.edu> To: freebsd-questions@freebsd.org Subject: Re: Shell scripting: Absolute path name of a file given as parameter Message-ID: <461DF63A.3010507@u.washington.edu> In-Reply-To: <33E0F3313625E543ACCC41AE2DFD5EF5024280@BB06.bolsabilbao.local> References: <33E0F3313625E543ACCC41AE2DFD5EF5024280@BB06.bolsabilbao.local>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?461DF63A.3010507>