I have the following in a directory:
1/
2/
3/
4/
5/
active -> 1
previous -> 2
Those are folders, as well as two symbolic links pointing to a folder. I want to delete all folders that are not being pointed to in the symbolic links, and not delete the symbolic links. I have tried the following
find . -maxdepth 1 -mindepth 1 -type d -not -path "$(readlink -f active)" -not -path "$(readlink -f previous)"
This still returns the two directories I want excluded. What's wrong here?
find
output? You said you want to delete all that are not pointed to by the symlinks, but thefind
expression seems to try to filter out exactly the ones pointed to by the symlinks? So, could you edit the question to clarify a bit?