1

I would like to list all commands available in $PATH.

Any idea ?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

2

Here is a quick onliner that will complete the task as long as you have the rights to view the folders.

for pathitem in $(echo $PATH | sed -e 's/:/ /g'); do echo $pathitem; ls -la $pathitem; echo ""; done

This code will also display the path above the listing and a space underneath it, similar to completing a ls -laR

thebtm
  • 1,395
  • while this would be close, it lists all files in each $PATH directory; maybe there are some files there that aren't executable, and thus shouldn't be considered "commands" – Jeff Schaller Mar 02 '18 at 23:15
  • I was just trying to show a quick one liner for the general idea. – thebtm Mar 02 '18 at 23:26