Mint
Mint

Reputation: 16047

Delete a symbolic link when the original folder is deleted

I was thinking of using inotifywait to watch the original folder where the original folders are in, then whenever it detects that a folder has been deleted, then delete the same symbolic link in the other folder.

So my question is, is that the best way? Or are there better ways to delete a symbolic link when the original folder gets deleted?

Upvotes: 1

Views: 1237

Answers (1)

ghostdog74
ghostdog74

Reputation: 343211

i have not used inotify, but if it can integrate *nix's find command, you can use it to delete the link

find /folderpath -type l -delete

Upvotes: 1

Related Questions