Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How can I find out if a symbolic link exists, that points to /tmp?

I have an mpeg file that has been linked to in a number of directories. I need to replace all those links with links to a new file. How can I find all the links that point to that file? This is on a CentOS 5 machine.

share|improve this question

marked as duplicate by Daniel Beck Oct 8 '12 at 18:22

This question was marked as an exact duplicate of an existing question.

have you tried ll, if it shows something like -> it means it's a link, I don't remember very well how to do this – poz2k4444 Oct 8 '12 at 17:58

The below should do it. globstar should require bash 4.0+

shopt -s globstar

# Set the initial filename.  Can be had from $@ if you wanted to.

# Roll through pretty much the entire server
for file in /**; do
    if [[ -l "${file}" ]]; then
        tmp="$(readlink "${file}")"
        [[ "${tmp##*/}" == "${the_file##*/}" ]] && ls -l "${file}"
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.