0

Is it different from C-shell? I remember in C-shell, when we do

echo *

then the * is actually expanded by C-shell to all filenames in the current directory, so echo really doesn't need to do anything but to echo what is passed into it. But in C-shell, we really need to do

find . -name '*item.js*'

so that even filenames such as list-item.jsx will be matched any level down the directory. So it can't "expand" the * of the current directory, because what if the current directory doesn't have such names.

However, in Bash, I found that we can just use

find . -name *item.js*

(it will go deep down into your folders). So doesn't that mean

  1. Bash doesn't expand the * into actual arguments before passing to a command, unlike C-shell?
  2. Does that mean all commands running under Bash, such as echo has to take * and process it inside of the code of echo? But then what if you invoke C-shell and run echo -- then it is the same binary. Does that mean all commands must be able to handle * when its binary sees the * as the argument and must be able to handle it?
nonopolarity
  • 3,069
  • If there are no files in your current directory that match *item.js*, then the shell won't expand the glob, instead passing it along to find. – Jeff Schaller Jul 08 '17 at 14:25
  • 4
    oh... then with find, we really should use single quotes: '*item.js*', because, otherwise it depends on whether the current folder has that pattern... and it feels kind of probabilistic... – nonopolarity Jul 08 '17 at 14:41
  • I closed this as a dupe of another question because while the questions aren't the same, the answer explains what you observed as well. – terdon Jul 08 '17 at 15:43

0 Answers0