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.

1 Answer
1

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