in reply to Problem with symlink

Removing the original file creates "broken links". The symlink file only contains the path of original file used while creating the link.
In the following example, the size of symlink is only 8 bytes.
$ cat > orig.txt This is original file $ ln -s orig.txt lnk $ ls -ltr orig* lnk* -rw-r--r-- 1 vaibhav grp 22 Jun 17 22:31 orig.txt lrwxrwxrwx 1 vaibhav grp 8 Jun 17 22:32 lnk -> orig.txt $ cat lnk This is original file $ rm orig.txt $ ls -ltr orig* lnk* orig*: No such file or directory lrwxrwxrwx 1 vaibhav grp 8 Jun 17 22:32 lnk -> orig.txt $ cat lnk cat: cannot open lnk $

Replies are listed 'Best First'.
Re^2: Problem with symlink
by Eldan Aranye (Acolyte) on Jun 18, 2012 at 04:30 UTC

    Thanks for that. I have another question. Imagine this:

    I have a perl script that symlinks file A to file B in another location. I then use file B as input for another program. I did not delete file A, and I did not do any modifications on it, so I'm assuming there is no broken link. But then the program tells me that file B's empty. Has anyone encountered this problem before?

    Thanks in advance for any help!

      You've created link A to orig file B. It looks like:
      /path1/A -> /path2/B
      As per your statements, A is untouched. B is passed to another program. Is there any chance B has been modified?
      Did you verify the permissions on B?
      Because I can't think of any other scenario that would cause B to go empty.
      Note that A will still have non zero size (since it contains path of B).