Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Shells: User's Guide: HP 9000 Computers > Chapter 17 Shell Grammar

Command Separators and Terminators

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

Certain metacharacters are used by the shell to either separate or terminate commands in a line as well as perform special functions to the shell. For example:

date; ls &

where ; is the separator and & is the terminator. The date command prints out the current date and the ls command lists the files in the current directory.

Table 17-1 “Separating and Terminating Characters”, describes each of the special characters used by the POSIX and Korn Shells. For each special character, there is an example command line followed by that example's output (when possible). Some output is based on the files existing in the current directory; so your output will not match exactly the output shown in the examples unless you create the files.

The examples in this chapter use the following commands:

cat

concatenates, copies or prints files

date

prints the current date

echo

prints the arguments that follow the command

ll

prints a long listing of detailed information about files

lp

sends files to the printer

ls

lists the files in the current directory

mail

reads your mail or sends mail to another user

more

prints a file out for viewing on the display

ps

lists your current processes

who

lists the people logged into the system

whoami

prints the current user's name

Table 17-1 Separating and Terminating Characters

Character

Example

Description

;

$ whoami; ls
george
file1
file2
file3

Separates commands that are executed in sequence. In this example, ls is executed only after the whoami command completes.

&

$ lp prog.c &
[1] 4094
request id is lp-725
$ echo hello
hello

Indicates that the command is to be executed as a process asynchronously. That means you can run other commands immediately on the terminal while the previous command runs invisibly to you in the background. This sends the file prog.c to the line printer to be printed while freeing up your terminal for other work.

&&

$ ls .kshrc && echo yes
.kshrc
yes

Separate commands such that the second command only runs if the first one runs successfully, that is, its exit status is 0. In this example, if the ls fails to find the file then the echo is not executed.

||

$ mail || lsf
No mail.
file1
file2
file3

Separate commands such that the second command only runs if the first one fails, that is, its exit status is not 0. In this example, the lsf lists the files only if the mail command fails.

 

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-1991 Hewlett-Packard Development Company, L.P.