Symbolic Links

I am linking a directory as follows:

ln -sf /home/xxx/userid/real_files/* /home/xxx/userid/linked_files

This gives me symbolic links for all the files in the real_files directory in the linked_files directory. My question is, if I go and remove a file in the real_files directory and then go back to the linked_files directory and do an ls -l <file_name> that file shows up. Is this a known problem ? Even if I redo the link the file still appears to be in the real_files directory, the only way to remove the reference (that I've found) is to remove my linked_files directory and then do the link command again.

Thanks

Yes symbolic links can daggle. That is they can point to a non-existent file. They are supposed to do that and would be useless if they didn't. Remember that the main reason for symbolic was to cross mount points so you can create a symbolic link to a file in another file system. Now take your case and suppose that /home/xxx/userid/real_files is a mount point. When you unmount /home/xxx/userid/real_files, those symlinks are daggling. And during boot-up they will daggle until /home/xxx/userid/real_files is mounted.

And even if you think that symlinks should disappear when they daggle, that would be hard to do. There is no list of smylinks to a file. So finding the symlinks would involve searching for them. And what if the symlink resides on a filesystem not currently mounted? When it was finally was mounted it would have daggling symlinks. And there are other even more arcane problems that would happen with trying to do this.

In your case though, you could just remove the one daggling symlink. You don't need to recreate the whole directory.