'How do I delete all child directories not pointed at by a symlink? [closed]

I’m using bash shell on Ubuntu 16.04. I have a symlink set up like so

$ ls -al /home/myuser/web/current
lrwxrwxrwx 1 myuser myuser 40 Feb 25 15:49 /home/myuser/web/current -> /path/to/main/releases20220225152608

The “releases” directory contains several other directories

$ ls /path/to/main/releases
20220223111602
20220224122838
20220225152608

How would I delete all other child directories in “/path/to/main/releases“ that are not pointed at by the symlink, “/home/myuser/web/current”?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source