How to check if a parent directory is a symbolic link
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I want to check for the symbolic link in the middle of a complex shell script. I should not change the current directory. All I have is a variable with the complete path say /home/harry/abc_xyz/tom/install/ . I initially thought of tokenizing the string with "/", but I am not sure how we can tokenize strings in linux scripts.
Anomie, How can I launch a child shell to do that? Thanks for your reply.
Is there any constant information you know about the directory you want to test as a symlink? You either need to know the name of the directory you want to test, or you need a way to know where it will fall in the folder/subfolder hierarchy.
Without that there isn't a good way to test for it.
I have a varibale say $completePath = /home/tom/abc_xyz/tom/install/. From this I need a way to find out that the dir /home/tom/abc_xys is a symbolic link. I was just wondering if there is a way to parse the string.
I see what you are saying. Sorry for not making myself clear before. I dont know where exactly the symbolic link "abc_xyz" will be present in the complete path. So, I need to check each parent directory in the variable.
I wonder if there is a way, to parse the string with "/" delimiter, that would make my job easier.