21
3
I was messing around in terminal on Red Hat Linux, and when I typed the asterisk (*
) followed by return, and it executed one of the programs in my directory. Why?
My best guess is that Unix treated it as a wildcard so it executed the first alphabetic program.
Since my_program.exe
and one_of_my_programs.program
can be executed by simply typing the name of the file, the wildcard operator represents all the possible files. Since a program is first alphabetically, Unix executes it. Is this a correct judgement?
I think not all shells sort the expansion of
*
alphabetically, but bash is one that does. – aschepler – 2017-10-04T22:04:07.9231
@aschepler: all POSIX-conforming shells must; see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_03 para 3.
– dave_thompson_085 – 2017-10-05T08:43:22.913