Shell – Unix equivalent of the Windows environment variable PATHEXT

environment-variablesshell

I am wondering if there is a Unix equivalent for the Windows environment variable PATHEXT.

For those with no Windows background: Adding a file suffix to PATHEXT allows me to execute a script without typing that suffix in cmd.exe. For example, on my Windows computer, PATHEXT contains the suffix .pl and when I want to execute a Perl script in cmd.exe, I simply can type my-script and it gets executed. Yet, in order to execute the same script in bash, I need to write the full name: my-script.pl.

Since I work on both Windows and Unix currently, I almost always fall into the trap of forgetting to type the suffix when going to a Unix box again.

Best Answer

short: no

longer: shell scripts require a full filename, but you can define aliases for your commands to refer to them by various names. For example

alias my-script=my-script.pl
Related Question