Find symbolic links
January 2, 2025
—
Find symbolic links that point to a given file. ls -lR lists every file recursively, grep "^l" keeps only the symbolic links (their permissions start with l) and the second grep filters the ones pointing to the target. Then find shows in which directories those links live.
$ ls -lR |grep "^l" |grep backend-swarm.yml
lrwxrwxrwx 1 pbeja pbeja 58 ago 4 2023 cpe-securitygroup-swarm.yml -> ../../Templates/domain.com/sg/backend-swarm.yml
lrwxrwxrwx 1 pbeja pbeja 58 ago 4 2023 cpe-securitygroup-swarm.yml -> ../../Templates/domain.com/sg/backend-swarm.yml
lrwxrwxrwx 1 pbeja pbeja 58 abr 19 2024 cpe-securitygroup-back-swarm.yml -> ../../Templates/domain.com/sg/backend-swarm.yml
$ find . -name "cpe-securitygroup-swarm.yml"
./Europe/Backend/cpe-securitygroup-swarm.yml
./Asia/Backend/cpe-securitygroup-swarm.yml