Last active
June 15, 2025 21:35
-
-
Save thingsiplay/7c5f8838eb87c74d8ef21bc6512df8d1 to your computer and use it in GitHub Desktop.
List all existing program paths from your Bash's history.
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
#!/usr/bin/env bash | |
# 1. history and $HISTFILE do not work in scripts. Therefore a direct path to | |
# the file is needed. | |
# 2. awk gets the first part of the command line, resulting in the command name. | |
# 3. List of command names is then sorted and duplicate entries are removed. | |
# 4. type -P will expand command names to paths, similar to which. But it will | |
# also expand aliases and remove functions from the list. | |
# 5. Final output is then sorted again. | |
type -P $(awk '{print $1}' ~/.bash_history | sort -u) | sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment