Last active
January 9, 2025 22:07
-
-
Save rcastill/761552abcef6bff2823220c531a065d0 to your computer and use it in GitHub Desktop.
Get the latest version of a library installed in a linux system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the latest version of a library installed in a linux system. | |
# Usage: ./libver.sh lib | |
# Example: ./libver.sh cuda | |
# Explain: search for lib$lib.so in the system, then extract version from name. | |
# This assumes that the library "lib" can be found under /usr as: /path/to/liblib.so.x.y.z | |
if [ -z "$1" ]; then | |
>&2 echo "Usage: $0 lib" | |
exit 1 | |
fi | |
lib="$1" | |
set -o pipefail | |
find /usr -name "lib$lib.so*" | sed -e "s/.*lib$lib.so.\(.*\)/\1/g" | grep "^[0-9.]*$" | sort | tail -n 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment