PREV UP NEXT The UNIX Computer System at ARE (Edition )

2.5.1: Running Commands

The main job of the shell is to allow the user to invoke commands. The basic form of a UNIX command line is

$ command arguments

where command represents any executable UNIX command and arguments represent a list of words that are passed to the command for processing. For example, consider the following command line:

$ mv -f old_file new_file

The command is `mv', used by UNIX to rename files. In this case, the shell will pass three arguments to the `mv' command. The first argument, `-f', is called an option, because it controls how `mv' does its job. The last 2 arguments are file names. They tell `mv' which file to rename and what its new name should be.

Most UNIX commands take a variety of options which control how they operate. In the old days, options were written as a dash followed by a single letter, usually a mnemonic for that option's purpose. For instance, in the above example, the `-f' option tells `mv' to forcibly rename `old_file' to `new_file' even if a file already exists with the new name. As programs have become more complicated, people have an increasingly hard time remembering what all these single character option letters mean. A new standard is emerging that supports long options prefixed with two dashes. So instead of typing the short option form `-f', `mv' also supports the long-option form `--force', which is even more mnemonic.

An important option that many UNIX commands support is `--help' (with short form `-h'). This option, if supported, will print out a short usage message indicating how to invoke the command. See Usage Statements, for details.