get /full/path/filename.ext from filename.ext

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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?

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux