In the answer to the question by the_undefined about how to remove a hardlink to a directory without removing the contents of other directories to which it is linked: As far as I can tell, it can't be done from the command line using builtin commands. However, this little program (inspired by Freeman's post) will do it:
#include <unistd.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
if (argc != 2) {
fprintf(stderr,"Use: hunlink <dir>\n");
return 1;
}
int ret = unlink(argv[1]);
if (ret != 0)
perror("unlink");
return ret;
}
To follow on with Freeman's example,
$ gcc hunlink.c -o hunlink
$ echo "foo bar" > child1/baz.txt
$ ./hunlink parent/clone2
will remove the hardlink at parent/clone2, but leave the directory child1
and the file child1/baz.txt
alone.