[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] bash, full filename
- Subject: [ale] bash, full filename
- From: joe at madewell.com (Joe Steele)
- Date: Sat Nov 29 19:12:47 2003
On Saturday, November 29, 2003 1:50 PM, David Corbin wrote:
>
> How can I take a filename (which may or may not be relative) and convert it to
> be a fully qualified filename, in bash?
I'm presuming that if it is relative, you mean that it is relative to
$PWD, and if it is not relative, then you mean that it begins with
"/".
Well, as a first stab at it, how about:
if [ -n "${filename%%/*}" ] ; then filename="${PWD}/$filename" ; fi
This assumes that the name is stored in $filename. It checks if the
name has a leading slash, and if not, it prepends the name with $PWD.
There's probably a better way.... But this way is done all within bash
without external commands.
--Joe