awk in bash with ls and variable

This is exactly why you should not use UPPER_CASE_VARS. $PATH is a variable used by the shell to find executables on your system. As soon as you over-write it with user input, your script can no longer find anything that does not reside in whatever the input was. In this case, you entered /bin, so your script can find /bin/ls but awk is not there.

The command_not_found_handle (see /etc/bash.bashrc) stepped in to give you a suggestion.

Leave a Comment