In shell scripting, there is a concept called positional parameters. Essentially, you can pass 'n' number of arguments to a shell script or function from the command line. They are then stored in special variables named
$2, and so on, which are then accessible inside the shell script. One point to note is the
$0 variable refers to the script itself.
Taking your script as an example, you could run it in the following manner:
Here, the parameter
/opt/src-code gets stored into the positional variable
$1. Your script then reassigns that value to another variable named
path. Then the statement is effectively
path variable then gets passed to the
grep command as its argument. It then determines where to actually run the grep command and look for pattern matches. There is an
if specified in your script, which checks if
grep does return any value.
In effect, the above steps get reduced to the following
grep command at runtime (ignoring the
grep -q -rHl --include \*.c --include \*.h "int main" /opt/src-code