Find folders with a specific name and without a symbolic link to them

I am trying to write a shell script under linux that lists all folders (recursively) with a specific name and a no symlink pointing to it.

For example, I have:

/home/htdocs/cust1/typo3_src-4.2.11
/home/htdocs/cust2/typo3_src-4.2.12
/home/htdocs/cust3/typo3_src-4.2.12

Now I want to go through all the subdirectories / home / htdocs and find those typo3_ * folders that are not pointed somewhere.

It should be possible with shellscript or a command, but I have no idea how to do this.

thanks for the help

Stephen

+3
source share
1 answer

, , node, , , . , . /home/htdocs, , :

# find specified folders:
find /home/htdocs -name 'typo3_*' -type d | while read folder; do
    # list all symlinks pointing to $folder
    find -L /home/htdocs -samefile "$folder"|grep -v "$folder\$"
done
+1

Source: https://habr.com/ru/post/1739686/


All Articles