Created
December 24, 2016 20:35
-
-
Save rich-97/9ceec2af7af2e2919170c6e89ae049eb to your computer and use it in GitHub Desktop.
List all binaries of directories in $PATH.
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 | |
list=${PATH//:/' '} | |
list=${list//\}/' '} | |
list=${list//\{/' '} | |
color () { | |
if [ -z $1 ]; then | |
tput setaf 1 | |
else | |
tput setaf $1 | |
fi | |
} | |
lsbin () { | |
sum=0 | |
for i in $list; do | |
if [ -d $i ]; then | |
files=$(ls $i) | |
else | |
color; echo "Directory no valid." | |
continue | |
fi | |
for j in $files; do | |
if [ -x $i/$j ]; then | |
let sum+=1 | |
color 2; echo -n $j | |
color 3; echo " $(du -k $i/$j | cut -f 1)kb" | |
fi | |
done | |
done | |
color 6; echo "total: $sum" | |
} | |
lsbin | sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment