Skip to content

Instantly share code, notes, and snippets.

@OneCDOnly
Created October 9, 2020 03:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OneCDOnly/f0a756e33d82ede0f2f7de1b0ecdb511 to your computer and use it in GitHub Desktop.
Save OneCDOnly/f0a756e33d82ede0f2f7de1b0ecdb511 to your computer and use it in GitHub Desktop.
find unused BASH functions in script
#!/usr/bin/env bash
target_pathfile="$1"
target_func=''
for target_func in $(grep '()$' "$target_pathfile" | grep -v '=\|\$' | sed 's|()||g'); do
[[ $(grep -ow "$target_func" < "$target_pathfile" | wc -l) -eq 1 ]] && echo "$target_func()"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment