Expanding file names in a script? ../blah -> /home/blah
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
[tink@diggn:~/test]$ cd /usr/local/lib
[tink@diggn:/usr/local/lib]$ ~/test/full_path ../share/ImageMagick/../aclocal
/usr/local/share/aclocal[tink@diggn:/usr/local/lib]$ ~/test/full_path ~/test/../documents
/home/tink/documents[tink@diggn:/usr/local/lib]$
Note that "/home/tink/documents[tink@diggn:/usr/local/lib]$" in
the output is NOT an error ... and if you don't want it to
do this, fix it by appending << endl to the cout statement ;)
Again, wow! Thanks Tink, that is what I wanted. But, oh I'm so stupid... Ever heard of the -ef test? It checks if two files are the same... Now I can solve VisionZ's problem
Originally posted by Bebo Thanks a lot for the suggestion. Hm, it seems I don't have it. But on the other hand, from the man page it seems like a C command.
LOL, look at this - from the man page:
OK, so... I guess I won't
you are indeed looking at the man page for a c function of the same name. (man section 3, if i remember correctly). the command i am referring to is obviously not installed on your system, but its man page would be located in section 1, if it were.
on a side note, the reason that the c routine's man page says that it is broken is because it is impossible to know ahead of time that a particular path name will be small enough to alloc enough memory to hold it. thus, even if you alloc PATH_MAX (or whatever) space for the output of your path, you may overflow it, which is obviously a security risk. however, you can't avoid this problem, no matter which routine you choose for the purpose.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.