[CentOS] get /full/path/filename.ext from filename.ext

Tue Dec 9 20:57:03 UTC 2014
ken <gebser at mousecar.com>

This should be simple, but it's not, unless I'm forgetting something.

Writing a script, an arg is a filename.  So

fname=$1

But I want that expanded to include the full path and filename, not just 
what is given as the arg on the command line.

E.g., if the user's cwd is /home/joe/a/b/c/ and he specifies

../x/file-a.ext

then the function/utility should transform that into the absolute path 
with filename:

/home/joe/a/b/x/file-a.ext

In the simplest scenario, the answer would be $PWD/file-a.ext, but that 
would by no means cover a portion of the possible scenarios.

You'd think this functionality would be included already in one or 
another linux utility.  It's kinda like the complement to the 'basename' 
utility.  I've looked into the dark corners of ls, stat, file, bash, 
type, find, and a few other linux standards, but nothing seems to do this.

Any gurus out there know the utility which does this?