Skip to content

A note on arguments and parameters

Ryan edited this page Aug 11, 2023 · 1 revision

Arguments can be input into a command in several ways

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:

keyword arguments

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).

positional arguments

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).

flag arguments

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.