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

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



I don't know if this is of interest as an alternative.

I did find a cool functionality called locate  and updatedb
Updatedb creates the database of your files, locate does superfast searches.

It essentially does a superfast "find" on your root filesystem, giving you the fully qualified path of all hits.
You can create db's on your other filessytems.

The problem is that it can get stale, but you can update it before doing your searches. Plus it gives you a fully qualified path name with the results.

So if you need to do a set of searches on a filesystem (or whole system)

run updatedb on each target filesystem to create the db for that filesystem.
then use locate to search each filesystem "db"...
it takes seconds like ls instead of minutes like find....the more files in the FS, the quicker the searches compared to other tools.

the best part is you can run the db's when your systems are quiet, and the databases use minimal diskspace.


On 12/9/2014 2:57 PM, ken wrote:
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

_______________________________________________
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