$title = "About Unix commands"; $area = "Unix Support"; $metadata = "unix, command, syntax, options, arguments"; $pfloc = ""; require '/usr/local/wwwdocs/ucs/fragments/header.phtml'; require '/usr/local/wwwdocs/ucs/fragments/header-bc.phtml'; ?>
The basic form of any Unix command is:
Most descriptions for commands such as those given in the On-line Manual use a much more precise syntax. For example:
cp [-iprR] filename ... directory
This syntax has a few simple rules. Apply them to the command description and you can understand how the command is to be used.
Any options or arguments enclosed in [] square brackets are optional.
Anything not enclosed in [] square brackets must be entered.
Boldface words must be typed exactly as they appear. This usually applies to the command name and command options.
Arguments shown in italics must be replaced by whatever it is that they represent. This is usually the name of a file or directory.
Ellipses '...' mean that the previous argument can be repeated any number of times.
Options modify the way that a command works. They usually consist of a hyphen followed by a single letter.
For example the wc command counts the number of words, characters and lines in a file. By using a different option you can choose what is counted.
wc -w file1 | counts the words |
wc -c file1 | counts the characters |
wc -l file1 | counts the lines |
Some commands accept multiple options. These can be grouped together after a single hyphen:
command -abc argument
A small number of commands require each option to be given separately. Check the command synopsis for a command to see how a command requires its options to be given.
An option that takes an argument, such as the name of a printer or a file, is given separately.
An argument is a number, character or word which changes the action of the command it is applied to. Most commands are used together with one or more arguments, such as a file name. For some commands these arguments are optional. If the argument contains an empty space then it must be quoted.
To use a command with no argument:
date
Entered on its own this command displays the current time and date.
To use a command with a single argument:
cd newdir
The cd command (used to change from one directory to another) takes the name of the directory newdir as its argument.
To use a command with several arguments:
cat file1 file2 file3
The cat command takes the names of three files as arguments. It prints file1 followed by file2 and then file3 on the screen. This explains the name of the command - it concatenates any files given to it as arguments.
To 'quote' an argument:
ls 'part 1'
This lists information about the file part 1. The quotation marks ensure that the shell interprets the command line as the ls command followed by a single argument 'part 1'.
If the quotation marks were left out, the shell would interpret the command line as an instruction to list information about the file part and then the file 1.
require '/usr/local/wwwdocs/ucs/fragments/footer.phtml'; ?>