I am trying to understand how grep works.
When I say grep "hello" *.*, does grep get 2 arguments — (1) string to be searched i.e. “hello” and (2) path *.*? Or does the shell convert *.* into something that grep can understand?
Where can I get source code of grep? I came across this GNU grep link. One of the README files says its different from unix grep. How so?
I want to look at source of FreeBSD version of grep and also Linux version of it (if they are different).
The shell does the globbing (conversion from
*form to filenames). You can see this by if you have a simple C program:And then run it like this:
You’ll see it prints out what matched, not
*literally. If you invoke it like this:You’ll see it gets a literal
*.