Skip to content

Instantly share code, notes, and snippets.

@breun
Last active October 8, 2015 08:59
Show Gist options
  • Save breun/3309543 to your computer and use it in GitHub Desktop.
Save breun/3309543 to your computer and use it in GitHub Desktop.
This script lists all commands that appear more than once in your $PATH. For of each command its locations and the number of occurrences are displayed.
#!/bin/bash
#
# This script lists all commands that appear more than once in your $PATH.
# For of each command its locations and the number of occurrences are displayed.
#
# Nils Breunese <[email protected]>, 2012.
for command in `compgen -c`
do
count=`which -a $command | wc -l | tr -d ' '`
if [ "$count" -gt "1" ]
then
echo "$command: `which -a $command | tr '\n' ' '`($count)"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment