LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Symbolic link does not work ( or is it me ) ? (https://www.linuxquestions.org/questions/linux-newbie-8/symbolic-link-does-not-work-or-is-it-me-678348/)

uncle-c 10-22-2008 12:34 PM

Symbolic link does not work ( or is it me ) ?
 
Hi there.
I created a small text file and saved it as data.txt. I then proceeded to make a symbolic link to this file :

Code:

$ ln -s data.txt data.sym
I done a "cat" on data.sym and I got a listing of the contents of the original data.txt file. I moved the symbolic link to a different directory, cd to that directory and when I cat the symbolic link I get
Code:

cat: data.sym: No such file or directory
I was expecting the contents of the data.txt file to be shown.

I also done this :

Code:

$ ln -s data.txt ~/temp/data.sym
I moved to the temp directory and same thing again, I done cat on data.sym and got the "No such file or directory" error. Is this expected behaviour ? If so why ? The original file and symlink don't have to reside in the same directory do they ?

Thanks
UC

Total-MAdMaN 10-22-2008 01:40 PM

I'm not sure why the second one is having problems, but the problems with the first could be because you moved the symlink. It is looking for the file in the current directory, as you created it in the same directory as the file it references. When you moved it it's now looking for the original file in the directory you moved the symlink to.


All times are GMT -5. The time now is 07:11 AM.