Last active
April 11, 2017 15:11
-
-
Save JayGoldberg/e10ff418ac98c27fdfda3e3d41f18643 to your computer and use it in GitHub Desktop.
LINUX: Find all executables in $PATH that are likely XWindows (GUI) applications
This file contains 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 | |
## @author Jay Goldberg | |
## @email jaymgoldberg@gmail.com | |
## @license Apache 2.0 | |
## @description Find all executables in $PATH that are likely XWindows (GUI) applications | |
## @usage findXapps.sh | |
#======================================================================= | |
# a substring of the dynamically linked library that determines if the exe is an X app | |
library="libX" | |
#library="xcb" | |
testbin() { | |
if [[ $(ldd "$1" | grep -i "$library") ]]; then echo "$1";fi | |
} | |
# make it available to the bash invocation that happens next | |
export -f testbin | |
export library | |
# this path split does not work with paths that have spaces :( | |
for path in $(echo $PATH | tr ':' ' '); do | |
find "$path" -executable -type f -exec bash -c 'testbin "{}"' \; | |
done | |
unset -f testbin | |
unset library |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment