Skip to content

Instantly share code, notes, and snippets.

@ronakjain2012
Created May 5, 2018 17:16
Show Gist options
  • Save ronakjain2012/72fa509aa6f8a26082f306e429d19174 to your computer and use it in GitHub Desktop.
Save ronakjain2012/72fa509aa6f8a26082f306e429d19174 to your computer and use it in GitHub Desktop.
count the executable files available in your environment variable in Linux shell
envpath="$PATH"
sum=0
IFS=':'
read -ra ADDR <<< "$envpath"
for x in "${ADDR[@]}"; do
cd "$x"
for y in `ls -l | grep -E "[d\-](([rw\-]{2})x){1,3}"`; do
sum=$((1 + sum))
done
done
echo "$sum"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment