Executables as a general term for:
- common binaries
I suppose it can be done with some fat regex, matching start of new lines, conjunctions like
||, inline after
; etc...but I was wondering is there a simpler way?
You might be happy enough just collating the "words", then pass them through the ``which` command. Perhaps like the following:
cat $SCRIPT | tr -c '[[:alnum:]-_]' '\\n' | sort -u | xargs which
The word collation in the
tr phrase excludes the more "esoteric" commands like
[ and such. That's where you might need to experiment unless you're just looking for "ordinary" command words. The above of course also finds command words that perhaps are not used as such in the script, and to make that distinction you'll indeed need more of a parser. And you might as well want an initial
sed 's/#.*// rather than
cat to exclude the comments in the script (although that fails to pass where
# is included in strings).