Unix command line 101: How much do you know?

Unix Insider |  Operating Systems

A Unix command line is a sequence of characters in the syntax of the
target shell language. Of the characters found there, some are known as metacharacters, which have a special meaning to the shell. The
metacharacters in the Korn shell are:

  • ; Separates multiple commands on a command line
  • & Causes the preceding command to execute synchronously (i.e., at the same time as the next command on the command line)
  • () Launches commands enclosed in parentheses in a separate shell
  • | Pipes the output of the command to the left of the pipe to the input of the command on the right of the pipe
  • > Redirects output to a file or device
  • < Redirects input from a file or device
  • Newline Ends a command or set of commands
  • Space Separator between command words
  • Tab Separator between command words

(Note: Some of these metacharacters can be used in
combinations, such as || and &&. Consult your manual for a complete

With these metacharacters in mind, you can define a command line
-- a sequence of characters separated by one or more
nonquoted metacharacters. In the following example, the passwd file
is piped through the cut program, and fields 1 and 3 are output based on a colon

In the following command line,

cat /etc/passwd|cut -d ":" -f 1,3 >usruid.txt

the words are:


Note that the metacharacters |, >, and the space have been removed, and
that the metacharacters &, |, (), ;, and the newline are used to separate or
terminate multiple commands within a command line.

In our example command line, there are two commands separated by
the pipe (|) symbol:

cat /etc/passwd


Join us:






Operating SystemsWhite Papers & Webcasts

See more White Papers | Webcasts

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Ask a Question