I have a book that says that the output of the command echo *
is the line that follows below. I can't find why it outputs that. Please help.
$ echo *
local.cshrc local.login local.profile
*
is shell special character (glob match) that matches the names of files and directories in the current directory.
$ ls *
This will list all files and directories in current directory. So, in your case '*' returns and 'echo' prints them on the console. Try this to confirm:
$ x=*
$ echo $x
You are using a wildcard - *
which is used with globbing
and file-expansion
.
The referenced link above describes this further:
Standard wildcards (also known as globbing patterns) are used by various command-line utilities to work with multiple files. For more information on standard wildcards (globbing patterns) refer to the manual page by typing:
and
*
(asterisk) this can represent any number of characters (including zero, in other words, zero or more characters). If you specified a "cd*" it would use "cda", "cdrom", "cdrecord" and anything that starts with “cd” also including “cd” itself. "m*l" could by mill, mull, ml, and anything that starts with an m and ends with an l.