-
Notifications
You must be signed in to change notification settings - Fork 0
A note on arguments and parameters
Most commands have a set of inputs that alter the way the command behaves (use 'man ' or 'command --help' to see these options). Generally, there are thee types of inputs: keyword, positional, and flag. Here are some examples of each:
head -n 5 <file>
In this case, 5 is associated with the parameter
"-n" which means it is a keyword argument ("n" is the key and "5" is the value or argument
you provide).
cat <file1> <file2>
In this case, "file1" and "file2" are going to be positional arguments, meaning they are always expected in a certain position. Here, they must always be the last inputs into the cat command. They're not preceded by any letter or variable name, their use is dependent on them showing up in a specific spot (and sometimes order).
grep -c <search term> <file>
In this case, "-c" is basically an on/off switch that tells grep whether to print out the number of lines in the file that match the search term. This type of input is called a flag.
Notice that the search term that follows "-c" is not actually directly associated with it, which differs from keyword arguments.