Skip to content

Instantly share code, notes, and snippets.

@demmm
Last active February 4, 2024 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save demmm/fc966e6becfea19ec27ac7421734ccd8 to your computer and use it in GitHub Desktop.
Save demmm/fc966e6becfea19ec27ac7421734ccd8 to your computer and use it in GitHub Desktop.
check-links.sh
#!/bin/bash
# This is a simple script which detects broken binaries and libraries
# this script is licensed under the GPL
#
files=$(find /usr/bin -maxdepth 1 -type f)
libs=$(find /usr/lib/*.so* -maxdepth 1 -type f)
libs2=$(find /usr/lib/*/*.so* -maxdepth 1 -type f)
libs3=$(find /usr/lib/*/*/*.so* -maxdepth 1 -type f)
parse() {
local f="$1"
local p="$(ldd $f 2>/dev/null | grep 'not found' | awk '{print $1}' | sed -z 's/\s/ /g')"
if [ "$p" != "" ] ; then
echo "$(LC_ALL=C pacman -Qo $f) seem broken! → $p"
fi
}
clear
echo "Searching broken binaries...."
for binary in $files ; do
parse ${binary}
#parse=$(ldd ${binary} | grep "not found")
#if [ "${parse}" != "" ] ; then
# echo "$(LC_ALL=C pacman -Qo $binary) seems broken!"
#fi
#unset parse
done
echo " "
echo "Searching broken libs...."
for lib in $libs ; do
if [ -x ${lib} ] ; then
parse ${lib}
#parse=$(ldd ${lib} | grep "not found")
#if [ "${parse}" != "" ] ; then
# echo "$(LC_ALL=C pacman -Qo $lib) seems broken!"
#fi
#unset parse
fi
done
for lib in $libs2 ; do
if [ -x ${lib} ] ; then
parse=$(ldd ${lib} | grep "not found")
if [ "${parse}" != "" ] ; then
echo "$(LC_ALL=C pacman -Qo $lib) seems broken!"
fi
unset parse
fi
done
for lib in $libs3 ; do
if [ -x ${lib} ] ; then
parse=$(ldd ${lib} | grep "not found")
if [ "${parse}" != "" ] ; then
echo "$(LC_ALL=C pacman -Qo $lib) seems broken!"
fi
unset parse
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment