Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
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
add comment

1 Answer 1

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.
the_file="filename.mpg"

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

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