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
  • 2
    Bash globbing and filename expansion – George Vasiliou Mar 18 '17 at 10:58

* 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 
  • ls * is slightly different from echo *; mkdir p; touch p/j – Jeff Schaller Mar 18 '17 at 14:43
  • Agree. ls * will also display the content of first level subdirectories. – Sharad Mar 18 '17 at 17:42

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:


* (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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.