Index of /unix/unixnut/index

        Name                    Last modified       Size  Description

  [DIR]  Parent Directory        09-Aug-1999 18:17      -
  [   ]  cjm-wz.log              09-Aug-1999 18:18    13k
  [TXT]  idx_0.htm               09-Aug-1999 18:17     4k
  [TXT]  idx_a.htm               09-Aug-1999 18:17     9k
  [TXT]  idx_b.htm               09-Aug-1999 18:17     6k
  [TXT]  idx_c.htm               09-Aug-1999 18:17    20k
  [TXT]  idx_d.htm               09-Aug-1999 18:17    11k
  [TXT]  idx_e.htm               09-Aug-1999 18:17    12k
  [TXT]  idx_f.htm               09-Aug-1999 18:17    15k
  [TXT]  idx_g.htm               09-Aug-1999 18:17     6k
  [TXT]  idx_h.htm               09-Aug-1999 18:17     7k
  [TXT]  idx_i.htm               09-Aug-1999 18:17     7k
  [TXT]  idx_j.htm               09-Aug-1999 18:17     4k
  [TXT]  idx_k.htm               09-Aug-1999 18:17     5k
  [TXT]  idx_l.htm               09-Aug-1999 18:17    10k
  [TXT]  idx_m.htm               09-Aug-1999 18:17    10k
  [TXT]  idx_n.htm               09-Aug-1999 18:17     7k
  [TXT]  idx_o.htm               09-Aug-1999 18:17     5k
  [TXT]  idx_p.htm               09-Aug-1999 18:17    13k
  [TXT]  idx_q.htm               09-Aug-1999 18:17     3k
  [TXT]  idx_r.htm               09-Aug-1999 18:17    12k
  [TXT]  idx_s.htm               09-Aug-1999 18:17    19k
  [TXT]  idx_t.htm               09-Aug-1999 18:18    11k
  [TXT]  idx_u.htm               09-Aug-1999 18:18    11k
  [TXT]  idx_v.htm               09-Aug-1999 18:18     5k
  [TXT]  idx_w.htm               09-Aug-1999 18:18     7k
  [TXT]  idx_x.htm               09-Aug-1999 18:18     3k
  [TXT]  idx_y.htm               09-Aug-1999 18:18     3k
  [TXT]  idx_z.htm               09-Aug-1999 18:18     3k
Apache/1.3.3 Server at self-evident.com Port 80


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: A

a command (sed) : Chapter 10, Reference: a
abbrev command (ex) : Chapter 9, Reference: abbrev
abbreviations commands (emacs) : 7.2.9. Word Abbreviation Commands
aborted programs
clearing terminal settings : Chapter 2, Reference: reset
debugging resulting files : Chapter 2, Reference: sdb
access modes, changing : Chapter 2, Reference: chmod
active processes, reports on : Chapter 2, Reference: ps
addresses for ex commands : 9.1.2. Addresses
addresses for sed commands : 10.3.1. Pattern Addressing
admin command (SCCS)
17.2.1. Creating an SCCS File
Chapter 17, Reference: admin
alias command
dbx debugger : Chapter 20, Reference: alias
ksh and sh shells : Chapter 4, Reference: alias
alias command (csh)
csh shell : Chapter 5, Reference: alias
aliases
for commands : Chapter 4, Reference: alias
email, displaying addresses for : Chapter 2, Reference: mailalias
aliases for commands
Chapter 4, Reference: unalias
Chapter 5, Reference: alias
alignment/positioning
emacs centering commands : 7.2.14. Centering Commands
emacs indentation commands
7.2.13. Indentation Commands
7.2.16. Basic Indentation Commands
of graphics, Pic preprocessor for : 16.3.8. Positioning
nroff/troff requests for : 12.5.6. Horizontal Positioning
append command (ex) : Chapter 9, Reference: append
appending to files
Chapter 2, Reference: ar
Chapter 2, Reference: cat
apropos command : Chapter 2, Reference: apropos
ar command : Chapter 2, Reference: ar
archives : Chapter 2, Reference: ar
copying : Chapter 2, Reference: cpio
link editing of : Chapter 2, Reference: lorder
removing information from : Chapter 2, Reference: strip
reorganizing : Chapter 2, Reference: tsort
args command (ex) : Chapter 9, Reference: args
argv shell variable : 5.3.3. Predefined Shell Variables
arithmetic expressions
csh shell : 5.4. Expressions
ksh shell : 4.4. Arithmetic Expressions
arithmetic operators (csh) : 5.4.1.2. Arithmetic Operators
arrays
assigning in awk : 11.6. Variables and Array Assignments
in Korn shell : 4.3.4. Arrays
as command : Chapter 2, Reference: as
ASCII character set
Chapter 2, Reference: lptest
21. ASCII Character Set
assembly language processing
as command : Chapter 2, Reference: as
cc command : Chapter 2, Reference: cc
assign command (dbx) : Chapter 20, Reference: assign
assignment operators (csh) : 5.4.1.1. Assignment Operators
at command : Chapter 2, Reference: at
atan2 command (awk) : Chapter 11, Reference: atan2
atq command : Chapter 2, Reference: atq
atrm command : Chapter 2, Reference: atrm
autoload command (ksh, sh) : Chapter 4, Reference: autoload
awk scripting language
Chapter 2, Reference: awk
11. The Awk Scripting Language
(see also nawk scripting language)
commands for : 11.7. Group Listing of Awk Commands
operators : 11.5. Operators
system variables : 11.4. Awk System Variables
variable and array assignment : 11.6. Variables and Array Assignments

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: B

b command (sed) : Chapter 10, Reference: b
background processes : Chapter 2, Reference: wait
banner command : Chapter 2, Reference: banner
basename command
Chapter 2, Reference: basename
(see also dirname command)
batch command : Chapter 2, Reference: batch
batch execution
at specified date/time
Chapter 2, Reference: at
Chapter 2, Reference: crontab
immediate : Chapter 2, Reference: batch
printing queued jobs : Chapter 2, Reference: atq
remove queued jobs : Chapter 2, Reference: atrm
bc command : Chapter 2, Reference: bc
bdiff command : Chapter 2, Reference: bdiff
bfs command : Chapter 2, Reference: bfs
bg command (csh) : Chapter 5, Reference: bg
bg command (ksh, sh) : Chapter 4, Reference: bg
bitwise operators (csh) : 5.4.1.3. Bitwise and Logical Operators
block size, changing : Chapter 2, Reference: dd
Bourne shell : (see sh)
branching commands (sed) : 10.4.5. Branching Commands
break command (awk) : Chapter 11, Reference: break
break command (csh) : Chapter 5, Reference: break
break command (ksh, sh) : Chapter 4, Reference: break
breaksw command (csh) : Chapter 5, Reference: breaksw
buffers (emacs) commands for : 7.2.10. Buffer Manipulation Commands
built-in shell variables
csh shell : 5.3.3. Predefined Shell Variables
sh and ksh shells : 4.3.2. Built-in Shell Variables
bundling commands : Chapter 2, Reference: xargs
bundling software packages : 1.2. Bundling

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: C

c command (sed) : Chapter 10, Reference: c
C programming
call-graph profile data for
displaying : Chapter 2, Reference: gprof
compiling
cc command : Chapter 2, Reference: cc
debugging : Chapter 2, Reference: ctrace
detecting bugs and errors : Chapter 2, Reference: lint
formatting files in : Chapter 2, Reference: cb
symbol cross-references : Chapter 2, Reference: cxref
C shell : (see csh)
C- commands (emacs) : 7.3.1. Control-key Sequences
cal command : Chapter 2, Reference: cal
calculator commands
bc command : Chapter 2, Reference: bc
dc command : Chapter 2, Reference: dc
calendar command : Chapter 2, Reference: calendar
calendars : Chapter 2, Reference: cal
call command (dbx) : Chapter 20, Reference: call
call-graph profile data for C programming : Chapter 2, Reference: gprof
calling out (cu command) : Chapter 2, Reference: cu
cancel command : Chapter 2, Reference: cancel
canceling commands (emacs) : 7.2.5. Stopping and Undoing Commands
capitalization : (see case)
case
converting : Chapter 2, Reference: dd
emacs commands for : 7.2.7. Capitalization Commands
case command (csh) : Chapter 5, Reference: case
case command (ksh, sh) : Chapter 4, Reference: case
cat command : Chapter 2, Reference: cat
catch command (dbx) : Chapter 20, Reference: catch
cb command : Chapter 2, Reference: cb
cc command : Chapter 2, Reference: cc
cd command (csh) : Chapter 5, Reference: cd
cd command (dbx) : Chapter 20, Reference: cd
cd command (ksh, sh) : Chapter 4, Reference: cd
cdc command (SCCS) : Chapter 17, Reference: cdc
CDPATH shell variable : 4.3.3. Other Shell Variables
cdpath shell variable : 5.3.3. Predefined Shell Variables
centering : (see alignment/positioning)
cflow command : Chapter 2, Reference: cflow
change command (ex) : Chapter 9, Reference: change
character sets, converting : Chapter 2, Reference: iconv
characters
ASCII character set : 21. ASCII Character Set
counting in files : Chapter 2, Reference: wc
Greek (Eqn preprocessor) : 16.2.4. Greek Characters
mathematical (Eqn preprocessor) : 16.2.2. Mathematical Characters
nroff/troff requests for : 12.5.5. Font and Character Size
chdir command (csh) : Chapter 5, Reference: chdir
check pseudo-command (sccs) : 17.6.2. Pseudo-commands
checksum, calculating : Chapter 2, Reference: sum
chgrp command : Chapter 2, Reference: chgrp
chkey command
Chapter 2, Reference: chkey
(see also keylogin command)
(see also keylogout command)
chmod command : Chapter 2, Reference: chmod
chown command : Chapter 2, Reference: chown
ci command (RCS)
18.2. Basic Operation
Chapter 18, Reference: ci
classifying files by data type : Chapter 2, Reference: file
clean pseudo-command (sccs) : 17.6.2. Pseudo-commands
clear command : Chapter 2, Reference: clear
clear command (dbx) : Chapter 20, Reference: clear
clock modes, setting : Chapter 2, Reference: stty
close command (awk) : Chapter 11, Reference: close
cmp : Chapter 2, Reference: cmp
co command (RCS)
18.2. Basic Operation
Chapter 18, Reference: co
cof2elf command : Chapter 2, Reference: cof2elf
COFF files, converting to ELF : Chapter 2, Reference: cof2elf
col command : Chapter 2, Reference: col
columns
merging file lines into : Chapter 2, Reference: paste
selecting from files : Chapter 2, Reference: cut
COLUMNS shell variable : 4.3.3. Other Shell Variables
comb command (SCCS) : Chapter 17, Reference: comb
combination modes, setting : Chapter 2, Reference: stty
combining files : Chapter 2, Reference: cat
comm command : Chapter 2, Reference: comm
command history
csh shell : 5.5. Command History csh shell
sh and ksh shells : 4.5. Command History
command mode (vi) : 8.1.2. Command Mode
command substitution (csh) : 5.5.1. Command Substitution
commands
aliases for
Chapter 4, Reference: alias
Chapter 4, Reference: unalias
Chapter 5, Reference: alias
awk scripting language : 11.7. Group Listing of Awk Commands
basic, list of : 1.4. Beginner's Guide
bundling : Chapter 2, Reference: xargs
for csh shell : 5.6. Built-in C Shell Commands
descriptions of, displaying : Chapter 2, Reference: whatis
emacs commands, list of : 7.2. Summary of Commands by Group
executing
after logout : Chapter 2, Reference: nohup
with multiple systems : Chapter 2, Reference: uux
wait between : Chapter 2, Reference: sleep
lower priority, executing : Chapter 2, Reference: nice
nroff/troff requests : 12.4. Default Operation of Requests
SCCS utility : 17.5. Alphabetical Summary of SCCS Commands
sed editor : 10.3. Syntax of Sed Commands
for sh and ksh shells : 4.6. Built-in Commands (Bourne and Korn Shell)
in sh and ksh shells
4.2.4. Command Forms
5.2.4. Command Forms
vi editor : 8.1.4. Syntax of Vi Commands
comments
in files, modifying : Chapter 2, Reference: mcs
in sh and ksh shells : Chapter 4, Reference: #
compacting files : (see compressing files)
comparing
directory contents : Chapter 2, Reference: dircmp
documents : Chapter 2, Reference: diffmk
files
Chapter 2, Reference: bdiff
Chapter 2, Reference: comm
diff command : Chapter 2, Reference: diff
diff3 command : Chapter 2, Reference: diff3
comparison operators (csh) : 5.4.1.4. Comparison Operators
compiling, regular expressions : Chapter 2, Reference: regcmp
compress command : Chapter 2, Reference: compress
compressing files : Chapter 2, Reference: pack
cont command (dbx) : Chapter 20, Reference: cont
continue command (awk) : Chapter 11, Reference: continue
continue command (csh) : Chapter 5, Reference: continue
continue command (ksh, sh) : Chapter 4, Reference: continue
control assignments, setting : Chapter 2, Reference: stty
control modes, setting : Chapter 2, Reference: stty
Control-key commands (emacs) : 7.3.1. Control-key Sequences
conversation between users
Chapter 2, Reference: talk
Chapter 2, Reference: write
converting
character sets : Chapter 2, Reference: iconv
COFF and ELF files : Chapter 2, Reference: cof2elf
files
string_files into msg_files : Chapter 2, Reference: mkmsgs
into tables : Chapter 2, Reference: yacc
number units : Chapter 2, Reference: units
coprocesses (Korn shell) : 4.2.6. Coprocesses
copy command (ex) : Chapter 9, Reference: copy
copying
archives : Chapter 2, Reference: cpio
files : Chapter 2, Reference: cp
between machines : Chapter 2, Reference: rcp
dd command : Chapter 2, Reference: dd
with remote systems : Chapter 2, Reference: uucp
lines from standard input : Chapter 2, Reference: vc
standard input
Chapter 2, Reference: tee
Chapter 2, Reference: tr
core images, creating : Chapter 2, Reference: gcore
cos command (awk) : Chapter 11, Reference: cos
cp command : Chapter 2, Reference: cp
cpio command : Chapter 2, Reference: cpio
create pseudo-command (sccs) : 17.6.2. Pseudo-commands
creating directories : Chapter 2, Reference: mkdir
crontab command : Chapter 2, Reference: crontab
crypt command : Chapter 2, Reference: crypt
cscope command : Chapter 2, Reference: cscope
csh (C shell) : 5. The C Shell
built-in commands, list of : 5.6. Built-in C Shell Commands
compared to sh and ksh : 3.5. Differing Features
expressions : 5.4. Expressions
invoking shell : 5.8. Invoking the Shell
job control : 5.7. Job Control
variables : 5.3. Variables
.cshrc file
5.2.1. Special Files
5.3.4. Example .cshrc File
csplit command : Chapter 2, Reference: csplit
ctags command : Chapter 2, Reference: ctags
ctrace commands : Chapter 2, Reference: ctrace
cu command : Chapter 2, Reference: cu
cursor-movement commands (emacs) : 7.2.2. Cursor Movement Commands
customizing login session : 3.2.2. Customization of Your UNIX Session
cut command
Chapter 2, Reference: cut
(see also join command; newform command; paste command)
cwd shell variable : 5.3.3. Predefined Shell Variables
cxref command : Chapter 2, Reference: cxref

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: D

D command (sed) : Chapter 10, Reference: D
d command (sed) : Chapter 10, Reference: d
data keywords, SCCS : 17.4. Data Keywords
data transmission, verifying : Chapter 2, Reference: sum
database files for email messages : Chapter 2, Reference: gencat
date/time
calendars : Chapter 2, Reference: cal
date command : Chapter 2, Reference: date
specifying with RCS : 18.3.5. Specifying the Date
temporal usage information
Chapter 2, Reference: time
Chapter 2, Reference: timex
dbx command : Chapter 2, Reference: dbx
dbx debugger : 20.2. The Dbx Debugger
dbxenv command (dbx) : Chapter 20, Reference: dbxenv
dc command
Chapter 2, Reference: dc
(see also bc command)
dd command : Chapter 2, Reference: dd
debug command (dbx) : Chapter 20, Reference: debug
debugging
aborted programs : Chapter 2, Reference: sdb
C programs
Chapter 2, Reference: ctrace
Chapter 2, Reference: lint
dbx command : Chapter 2, Reference: dbx
utilities for : 20. Program Debugging
default command (csh) : Chapter 5, Reference: default
deledit pseudo-command (sccs) : 17.6.2. Pseudo-commands
delete command (awk) : Chapter 11, Reference: delete
delete command (dbx) : Chapter 20, Reference: delete
delete command (ex) : Chapter 9, Reference: delete
deleting
directories : Chapter 2, Reference: rmdir
emacs commands for : 7.2.3. Deletion Commands
files from archives : Chapter 2, Reference: ar
delget pseudo-command (sccs) : 17.6.2. Pseudo-commands
delta command (SCCS)
17.2.2. Retrieving a File
Chapter 17, Reference: delta
deroff command : Chapter 2, Reference: deroff
description file lines (make) : 19.2. Description File Lines
description files : Chapter 2, Reference: make
detach command (dbx) : Chapter 20, Reference: detach
df command : Chapter 2, Reference: df
diacritical marks (Eqn) : 16.2.5. Diacritical Marks
diff command
Chapter 2, Reference: diff
(see also cmp command; sdiff command)
SCCS utility and : 17.2.4. Recording Changes
diff3 command : Chapter 2, Reference: diff3
diffmk command : Chapter 2, Reference: diffmk
diffs pseudo-command (sccs) : 17.6.2. Pseudo-commands
dircmp command : Chapter 2, Reference: dircmp
directories
comparing contents : Chapter 2, Reference: dircmp
creating : Chapter 2, Reference: mkdir
deleting
Chapter 2, Reference: rm
Chapter 2, Reference: rmdir
moving : Chapter 2, Reference: mv
navigating
Chapter 4, Reference: cd
Chapter 5, Reference: cd
news, accessing : Chapter 2, Reference: news
printing names of : Chapter 2, Reference: dirname
printing pathname of : Chapter 2, Reference: pwd
renaming : Chapter 2, Reference: mv
dirname command : Chapter 2, Reference: dirname
dirs command (csh) : Chapter 5, Reference: dirs
dis command : Chapter 2, Reference: dis
disassembling object files : Chapter 2, Reference: dis
disks
input/output : Chapter 2, Reference: cpio
reporting on disk space : Chapter 2, Reference: df
usage information : Chapter 2, Reference: du
display command (dbx) : Chapter 20, Reference: display
displaying
calendars : Chapter 2, Reference: calendar
escape sequences : Chapter 2, Reference: col
files
by screen : Chapter 2, Reference: more
logged-in users : Chapter 2, Reference: who
man pages
Chapter 2, Reference: man
Chapter 2, Reference: whatis
reverse linefeeds : Chapter 2, Reference: col
system status information : Chapter 2, Reference: who
ditroff program
12.1. Introduction
(see also troff program)
do command (awk) : Chapter 11, Reference: do
do command (ksh, sh) : Chapter 4, Reference: do
documents, comparing : Chapter 2, Reference: diffmk
done command (ksh, sh) : Chapter 4, Reference: done
down command (dbx) : Chapter 20, Reference: down
download command : Chapter 2, Reference: download
dpost command : Chapter 2, Reference: dpost
du command : Chapter 2, Reference: du
dump command (dbx) : Chapter 20, Reference: dump
dumps, octal : Chapter 2, Reference: od

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: E

echo command : Chapter 2, Reference: echo
echo command (csh) : Chapter 5, Reference: echo
echo command (ksh, sh) : Chapter 4, Reference: echo
echo shell variable : 5.3.3. Predefined Shell Variables
ed command : Chapter 2, Reference: ed
edit command : Chapter 2, Reference: edit
edit command (dbx) : Chapter 20, Reference: edit
edit command (ex) : Chapter 9, Reference: edit
edit pseudo-command (sccs) : 17.6.2. Pseudo-commands
editing
bfs command : Chapter 2, Reference: bfs
files
restrictions on : Chapter 2, Reference: red
editing commands (sed) : 10.4.1. Basic Editing
EDITOR shell variable : 4.3.3. Other Shell Variables
editors
stream : Chapter 2, Reference: sed
text : Chapter 2, Reference: vi
egrep command : Chapter 2, Reference: egrep
pattern-matching metacharacters : 6.2. Metacharacters, Listed by UNIX Program
ELF files, converting to COFF : Chapter 2, Reference: cof2elf
emacs editor : 7. The Emacs Editor
pattern-matching metacharacters : 6.2. Metacharacters, Listed by UNIX Program
email aliases, displaying addresses for : Chapter 2, Reference: mailalias
email messages
automatic replies to : Chapter 2, Reference: vacation
database files for : Chapter 2, Reference: gencat
encoding binary files for : Chapter 2, Reference: uuencode
internationalizing : Chapter 2, Reference: exstr
new, notifying user of : Chapter 2, Reference: notify
queues, removing : Chapter 2, Reference: ipcrm
reading
Chapter 2, Reference: mail
Chapter 2, Reference: mailx
retrieving from files : Chapter 2, Reference: gettxt
searching contents of : Chapter 2, Reference: srchtxt
searching for : Chapter 2, Reference: gettxt
sending
Chapter 2, Reference: mail
Chapter 2, Reference: mailx
to all users : Chapter 2, Reference: wall
permission status : Chapter 2, Reference: mesg
encoded files, recreating original file : Chapter 2, Reference: uudecode
encrypting
creating keys : Chapter 2, Reference: makekey
files : Chapter 2, Reference: crypt
end command (csh) : Chapter 5, Reference: end
endif command (csh) : Chapter 5, Reference: endif
enter pseudo-command (sccs) : 17.6.2. Pseudo-commands
env command : Chapter 2, Reference: env
ENV shell variable : 4.3.3. Other Shell Variables
environment variables : 5.3.5. Environment Variables
printing values of : Chapter 2, Reference: printenv
Eqn preprocessor : 16.2. Eqn
equations, formatting in nroff/troff : 16.2. Eqn
erasing : (see deleting)
ERRNO shell variable : 4.3.2. Built-in Shell Variables
error messages, formatting : Chapter 2, Reference: fmtmsg
esac command (ksh, sh) : Chapter 4, Reference: esac
escape sequences, displaying : Chapter 2, Reference: col
/etc/passwd file
4.2.1. Special Files
5.2.1. Special Files
/etc/profile file
4.2.1. Special Files
(see also shell variables)
eval command (csh) : Chapter 5, Reference: eval
eval command (ksh, sh) : Chapter 4, Reference: eval
evaluating expressions : Chapter 2, Reference: expr
ex editor
Chapter 2, Reference: ex
9. The Ex Editor
pattern-matching metacharacters : 6.2. Metacharacters, Listed by UNIX Program
search-and-replace examples : 6.4.1. Examples of Searching and Replacing
exec command (csh) : Chapter 5, Reference: exec
exec command (ksh, sh) : Chapter 4, Reference: exec
executed files, shared objects for : Chapter 2, Reference: ldd
executing commands
after logout : Chapter 2, Reference: nohup
of lower priority : Chapter 2, Reference: nice
wait between : Chapter 2, Reference: sleep
EXINIT environment variable : 5.3.5. Environment Variables
exit command (awk) : Chapter 11, Reference: exit
exit command (csh) : Chapter 5, Reference: exit
exit command (ksh, sh) : Chapter 4, Reference: exit
exit status : Chapter 2, Reference: test
commands : Chapter 2, Reference: true
exp command (awk) : Chapter 11, Reference: exp
expanding files
Chapter 2, Reference: unpack
(see also pack command; pcat command)
export command (ksh, sh) : Chapter 4, Reference: export
expr command : Chapter 2, Reference: expr
expressions, C shell : 5.4. Expressions
expressions, evaluating : Chapter 2, Reference: expr
exstr command : Chapter 2, Reference: exstr

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: F

face command : Chapter 2, Reference: face
factor command : Chapter 2, Reference: factor
false command : Chapter 2, Reference: false
false command (ksh, sh) : Chapter 4, Reference: false
fc command (ksh, sh)
4.5.2. The fc Command
Chapter 4, Reference: fc
FCEDIT shell variable : 4.3.3. Other Shell Variables
fg command (csh) : Chapter 5, Reference: fg
fg command (ksh, sh) : Chapter 4, Reference: fg
fgrep command : Chapter 2, Reference: fgrep
fi command (ksh, sh) : Chapter 4, Reference: fi
fignore shell variable : 5.3.3. Predefined Shell Variables
file command : Chapter 2, Reference: file
file command (dbx) : Chapter 20, Reference: file
file command (ex) : Chapter 9, Reference: file
file creation mode mask : Chapter 2, Reference: umask
file inquiry operators (csh) : 5.4.1.5. File Inquiry Operators
filec shell variable : 5.3.3. Predefined Shell Variables
filename metacharacters : 6.1. Filenames Versus Patterns
csh shell : 5.2.2. Filename Metacharacters
sh and ksh shells : 4.2.2. Filename Metacharacters
files
access and modification times, updating : Chapter 2, Reference: touch
binary, converting for email : Chapter 2, Reference: uuencode
breaking lines of : Chapter 2, Reference: fold
calculating checksum for : Chapter 2, Reference: sum
changing permissions : Chapter 2, Reference: chmod
classifying by data type : Chapter 2, Reference: file
combining into module : Chapter 2, Reference: ld
comments in, modifying : Chapter 2, Reference: mcs
comparing
Chapter 2, Reference: comm
Chapter 2, Reference: sdiff
compiling : Chapter 2, Reference: yacc
compressing
Chapter 2, Reference: compress
Chapter 2, Reference: pack
converting
character sets in : Chapter 2, Reference: iconv
string_files into msg_files : Chapter 2, Reference: mkmsgs
into tables : Chapter 2, Reference: yacc
copying
between machines : Chapter 2, Reference: rcp
dd command : Chapter 2, Reference: dd
with remote systems : Chapter 2, Reference: uucp
from tape : Chapter 2, Reference: tar
counting words/characters/lines of : Chapter 2, Reference: wc
deleting : Chapter 2, Reference: rm
description : Chapter 2, Reference: make
displaying
by page : Chapter 2, Reference: pg
profile data for : Chapter 2, Reference: prof
editing : Chapter 2, Reference: ex
bfs command : Chapter 2, Reference: bfs
restrictions on : Chapter 2, Reference: red
emacs commands for handling : 7.2.1. File-handling Commands
email messages : (see email messages)
encoded, recreating original file : Chapter 2, Reference: uudecode
encrypting and decrypting : Chapter 2, Reference: vi
expanding : Chapter 2, Reference: unpack
formatting
Chapter 2, Reference: newform
Chapter 2, Reference: pr
formatting lines in : Chapter 2, Reference: fmt
joining similar lines of : Chapter 2, Reference: join
listing
for current directory : Chapter 2, Reference: ls
related pairs of : Chapter 2, Reference: lorder
shared objects for : Chapter 2, Reference: ldd
those to be executed : Chapter 2, Reference: which
merging lines into columns : Chapter 2, Reference: paste
moving : Chapter 2, Reference: mv
on multiple systems, commands for : Chapter 2, Reference: uux
numbering lines in : Chapter 2, Reference: nl
ownership of, changing
Chapter 2, Reference: chgrp
Chapter 2, Reference: chown
packed, displaying : Chapter 2, Reference: pcat
paging : Chapter 2, Reference: more
printing
initial lines of : Chapter 2, Reference: head
lines specified : Chapter 2, Reference: tail
pseudonyms (links) for : Chapter 2, Reference: ln
recovering after crash : Chapter 2, Reference: vi
removing information from : Chapter 2, Reference: strip
renaming : Chapter 2, Reference: mv
restoring from tape : Chapter 2, Reference: tar
revision control
RCS utility : 18. The RCS Utility
SCCS utility
17. The SCCS Utility
18.4. Conversion Guide for SCCS Users
searching contents of
for matching text : Chapter 2, Reference: fgrep
for newline/null sequence : Chapter 2, Reference: strings
by pattern-matching : Chapter 2, Reference: awk
regular expressions for : Chapter 2, Reference: grep
searching for specific : Chapter 2, Reference: find
sending to printer : Chapter 2, Reference: lp
size of : Chapter 2, Reference: size
sorting : Chapter 2, Reference: tsort
lines in : Chapter 2, Reference: sort
removing duplicate lines : Chapter 2, Reference: uniq
source, sending : Chapter 2, Reference: uuto
splitting into multiple files : Chapter 2, Reference: split
symbol tables for
printing : Chapter 2, Reference: nm
transferring to/from remote sites : Chapter 2, Reference: ftp
uncompressing
Chapter 2, Reference: uncompress
Chapter 2, Reference: zcat
updating older versions of : Chapter 2, Reference: install
write-protected, deleting : Chapter 2, Reference: rm
find command : Chapter 2, Reference: find
finger command : Chapter 2, Reference: finger
fix pseudo-command (sccs) : 17.6.2. Pseudo-commands
flowcharting function calls : Chapter 2, Reference: cflow
FMLI (Form and Message Language Interpreter) : Chapter 2, Reference: fmli
fmli command : Chapter 2, Reference: fmli
fmt command : Chapter 2, Reference: fmt
fmtmsg command : Chapter 2, Reference: fmtmsg
fold command : Chapter 2, Reference: fold
fonts
loading to Postscript files : Chapter 2, Reference: download
nroff/troff requests for : 12.5.5. Font and Character Size
for command (awk) : Chapter 11, Reference: for
for command (ksh, sh) : Chapter 4, Reference: for
foreach command (csh) : Chapter 5, Reference: foreach
Form and Message Language Interpreter : Chapter 2, Reference: fmli
formatting error messages : Chapter 2, Reference: fmtmsg
formatting files
Chapter 2, Reference: newform
Chapter 2, Reference: pr
FPATH shell variable : 4.3.3. Other Shell Variables
Framed Acceess Command Environment : Chapter 2, Reference: face
free disk space, reporting : Chapter 2, Reference: df
ftp command : Chapter 2, Reference: ftp
func command (dbx) : Chapter 20, Reference: func
function command (awk) : Chapter 11, Reference: function
function command (ksh, sh) : Chapter 4, Reference: function
function names
listing
ctags command : Chapter 2, Reference: ctags

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: G

g command (sed) : Chapter 10, Reference: g
G command (sed) : Chapter 10, Reference: G
gawk scripting language
11.1. Command-line Syntax
(see also awk scripting language)
gcore command : Chapter 2, Reference: gcore
gencat command : Chapter 2, Reference: gencat
generating filenames : Chapter 2, Reference: basename
get command (SCCS)
17.2.2. Retrieving a File
Chapter 17, Reference: get
getline command (awk) : Chapter 11, Reference: getline
getopts command (ksh, sh) : Chapter 4, Reference: getopts
gettxt command : Chapter 2, Reference: gettxt
glob command (csh) : Chapter 5, Reference: glob
global command (ex) : Chapter 9, Reference: global
gmon.out file : Chapter 2, Reference: cc
goto command (csh) : Chapter 5, Reference: goto
gprof command
Chapter 2, Reference: gprof
(see also lprof command; prof command)
graphics
formatting in nroff/troff : 16.3. Pic
Greek characters (Eqn preprocessor) : 16.2.4. Greek Characters
grep command : Chapter 2, Reference: grep
pattern-matching metacharacters : 6.2. Metacharacters, Listed by UNIX Program
groups
displaying for user : Chapter 2, Reference: groups
file ownership for, changing : Chapter 2, Reference: chgrp
listing IDs for : Chapter 2, Reference: id
logging in to : Chapter 2, Reference: newgrp
groups command : Chapter 2, Reference: groups
gsub command (awk) : Chapter 11, Reference: gsub

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: H

H command (sed) : Chapter 10, Reference: H
h command (sed) : Chapter 10, Reference: h
hardpaths shell variable : 5.3.3. Predefined Shell Variables
hardware flow control modes
setting : Chapter 2, Reference: stty
hash command (ksh, sh) : Chapter 4, Reference: hash
hashstat command (csh) : Chapter 5, Reference: hashstat
head command : Chapter 2, Reference: head
help
emacs commands for : 7.2.17. Detail Information Help Commands
on-line manual : (see man pages)
help command (dbx) : Chapter 20, Reference: help
help command (SCCS) : Chapter 17, Reference: help
histchars shell variable : 5.3.3. Predefined Shell Variables
HISTFILE shell variable : 4.3.3. Other Shell Variables
history command : 5.5. Command History csh shell
history command (csh) : Chapter 5, Reference: history
history command (dbx) : Chapter 20, Reference: history
history command (ksh, sh) : Chapter 4, Reference: history
.history file : 5.2.1. Special Files
history shell variable : 5.3.3. Predefined Shell Variables
history, command
csh shell : 5.5. Command History csh shell
sh and ksh shells : 4.5. Command History
HISTSIZE shell variable : 4.3.3. Other Shell Variables
HOME environment variable : 5.3.5. Environment Variables
HOME shell variable : 4.3.3. Other Shell Variables
home shell variable : 5.3.3. Predefined Shell Variables
horizontal alignment : (see alignment/positioning)
horizontal spacing : (see whitespace)
host machine
Chapter 2, Reference: hostid
Chapter 2, Reference: hostname
hostid command : Chapter 2, Reference: hostid
hostname command
Chapter 2, Reference: hostname
(see also uuname command)
hyphenation
nroff/troff requests for : 12.5.7. Hyphenation

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: I

i command (sed) : Chapter 10, Reference: i
I/O processing commands (sed) : 10.4.3. Input/Output Processing
iconv command : Chapter 2, Reference: iconv
id command : Chapter 2, Reference: id
ident command (RCS) : Chapter 18, Reference: ident
identification keywords, SCCS : 17.3. Identification Keywords
if command (awk) : Chapter 11, Reference: if
if command (csh) : Chapter 5, Reference: if
if command (ksh, sh) : Chapter 4, Reference: if
IFS shell variable : 4.3.3. Other Shell Variables
ignore command (dbx) : Chapter 20, Reference: ignore
ignoreeof shell variable : 5.3.3. Predefined Shell Variables
images, formatting in nroff/troff : 16.3. Pic
incremental search commands (emacs) : 7.2.8. Incremental Search Commands
indentation, emacs commands for
7.2.13. Indentation Commands
7.2.16. Basic Indentation Commands
index command (awk) : Chapter 11, Reference: index
index, generating in Solaris 2.0 : Chapter 2, Reference: ptx
info pseudo-command (sccs) : 17.6.2. Pseudo-commands
input modes, setting : Chapter 2, Reference: stty
insert command (ex) : Chapter 9, Reference: insert
insert mode (vi) : 8.1.3. Insert Mode
install command : Chapter 2, Reference: install
int command (awk) : Chapter 11, Reference: int
integer command (ksh, sh) : Chapter 4, Reference: integer
interactive conversation
Chapter 2, Reference: talk
Chapter 2, Reference: write
internationalizing : Chapter 2, Reference: exstr
Internet directory, searching : Chapter 2, Reference: whois
interprocess communication facilities : Chapter 2, Reference: ipcs
invoking the shell
4.8. Invoking the Shell
5.8. Invoking the Shell
ipcrm command : Chapter 2, Reference: ipcrm
ipcs command : Chapter 2, Reference: ipcs
ismpx command
Chapter 2, Reference: ismpx
(see also layers command)

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: J

job control
for csh shells : 5.7. Job Control
for sh and ksh shells : 4.7. Job Control
in shell scripts : Chapter 2, Reference: jsh
jobs command (csh) : Chapter 5, Reference: jobs
jobs command (ksh, sh) : Chapter 4, Reference: jobs
join command : Chapter 2, Reference: join
join command (ex) : Chapter 9, Reference: join
jsh : 4.7. Job Control
jsh command : Chapter 2, Reference: jsh
jterm command
Chapter 2, Reference: jterm
(see also layers command)
jwin command : Chapter 2, Reference: jwin

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: K

k command (ex) : Chapter 9, Reference: k
keylogin command
Chapter 2, Reference: keylogin
(see also chkey command; keylogout command)
keylogout command
Chapter 2, Reference: keylogout
(see also chkey command; keylogin command)
keywords, RCS : 18.3.1. Keyword Substitution
keywords, SCCS : 17.3. Identification Keywords
kill command : Chapter 2, Reference: kill
kill command (csh) : Chapter 5, Reference: kill
kill command (dbx) : Chapter 20, Reference: kill
kill command (ksh, sh) : Chapter 4, Reference: kill
ksh (Korn shell) : 4. The Bourne Shell and Korn Shell
arithmetic expressions : 4.4. Arithmetic Expressions
built-in commands, list of : 4.6. Built-in Commands (Bourne and Korn Shell)
compared to sh and csh : 3.5. Differing Features
coprocesses : 4.2.6. Coprocesses
invoking shell : 4.8. Invoking the Shell
job control : 4.7. Job Control
setting restrictions on
Chapter 2, Reference: rksh
4.9. Restricted Shells
variables : 4.3. Variables

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: L

l command (sed) : Chapter 10, Reference: l
LANG shell variable : 4.3.3. Other Shell Variables
language command (dbx) : Chapter 20, Reference: language
layers
multiple, controlling from one terminal : Chapter 2, Reference: shl
in windowing terminals, resetting : Chapter 2, Reference: jterm
layers command : Chapter 2, Reference: layers
ld command : Chapter 2, Reference: ld
ldd command : Chapter 2, Reference: ldd
length command (awk) : Chapter 11, Reference: length
let command (ksh, sh) : Chapter 4, Reference: let
lex command
Chapter 2, Reference: lex
(see also yacc command)
lexical analysis programs, generating : Chapter 2, Reference: lex
limit command (csh) : Chapter 5, Reference: limit
line breaks, nroff/troff requests and : 12.3.3. Requests That Cause a Line Break
line command : Chapter 2, Reference: line
line information commands (sed) : 10.4.2. Line Information
line numbers
nroff/troff requests for : 12.5.9. Line Numbering
line-edit mode : 4.5.1. Line-edit Mode
LINENO shell variable : 4.3.2. Built-in Shell Variables
lines
breaking : Chapter 2, Reference: fold
counting in files : Chapter 2, Reference: wc
numbering in files : Chapter 2, Reference: nl
reading from standard input : Chapter 2, Reference: line
LINES shell variable : 4.3.3. Other Shell Variables
links
creating for files : Chapter 2, Reference: ln
editors : Chapter 2, Reference: ld
lint command : Chapter 2, Reference: lint
list command (dbx) : Chapter 20, Reference: list
list command (ex) : Chapter 9, Reference: list
listing files
in archives : Chapter 2, Reference: ar
to be executed : Chapter 2, Reference: which
for current directory : Chapter 2, Reference: ls
ln command : Chapter 2, Reference: ln
loading fonts to Postscript files : Chapter 2, Reference: download
local modes, setting : Chapter 2, Reference: stty
log command (awk) : Chapter 11, Reference: log
logged-in users
displaying list : Chapter 2, Reference: users
report on : Chapter 2, Reference: rwho
logging in
as another user : Chapter 2, Reference: su
changing to current window : Chapter 2, Reference: relogin
displaying name : Chapter 2, Reference: logname
to groups : Chapter 2, Reference: newgrp
logical operators (csh) : 5.4.1.3. Bitwise and Logical Operators
login command : Chapter 2, Reference: login
login command (csh) : Chapter 5, Reference: login
.login file : 5.2.1. Special Files
login sessions : (see sessions)
logname command : Chapter 2, Reference: logname
LOGNAME environment variable : 5.3.5. Environment Variables
logout command (csh) : Chapter 5, Reference: logout
.logout file : 5.2.1. Special Files
lorder command : Chapter 2, Reference: lorder
lowercase : (see case)
lp command : Chapter 2, Reference: lp
lpq command : Chapter 2, Reference: lpq
lpr command : Chapter 2, Reference: lpr
lprm command : Chapter 2, Reference: lprm
lprof command
Chapter 2, Reference: lprof
(see also gprof command; prof command)
lpstat command : Chapter 2, Reference: lpstat
lptest command : Chapter 2, Reference: lptest
ls command : Chapter 2, Reference: ls

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: M

M- commands (emacs) : 7.3.2. Meta-key Sequences
m4 : Chapter 2, Reference: m4
m4 command : Chapter 2, Reference: m4
machine faults
tracing : Chapter 2, Reference: truss
macro commands (emacs) : 7.2.15. Macro Commands
macro names, listing : Chapter 2, Reference: ctags
macros
Eqn preprocessor : 16.2.1. Eqn Macros
for make utility : 19.3. Macros
pic preprocessors : 16.3.1. Pic Macros
processing, nroff/troff requests for : 12.5.10. Macro and String Processing
processor for program files : Chapter 2, Reference: m4
Tbl preprocessor : 16.1.2. Tbl Macros
mail : (see email; email messages)
mail command : Chapter 2, Reference: mail
MAIL environment variable : 5.3.5. Environment Variables
mail shell variable : 5.3.3. Predefined Shell Variables
MAIL shell variable : 4.3.3. Other Shell Variables
mailalias command : Chapter 2, Reference: mailalias
MAILCHECK shell variable : 4.3.3. Other Shell Variables
MAILPATH shell variable : 4.3.3. Other Shell Variables
mailx command : Chapter 2, Reference: mailx
make command : Chapter 2, Reference: make
make command (dbx) : Chapter 20, Reference: make
make utility : 19. The make Utility
makefiles
overriding : Chapter 2, Reference: make
updating : Chapter 2, Reference: install
makekey command : Chapter 2, Reference: makekey
man command : Chapter 2, Reference: man
man pages
displaying : Chapter 2, Reference: man
displaying command descriptions in : Chapter 2, Reference: whatis
keyword lookup : Chapter 2, Reference: apropos
MANPATH environment variable : Chapter 2, Reference: man
map command (ex) : Chapter 9, Reference: map
margins, nroff/troff requests for : 12.5.14. Text Adjustments
mark command (ex) : Chapter 9, Reference: mark
match command (awk) : Chapter 11, Reference: match
mathematics
characters for (Eqn preprocessor) : 16.2.2. Mathematical Characters
equations, formatting in nroff/troff : 16.2. Eqn
mcs command : Chapter 2, Reference: mcs
me macros : 15. me Macros
measurements for nroff/troff : 12.3.2. Specifying Measurements
memory (disk space) : Chapter 2, Reference: df
merge command (RCS) : Chapter 18, Reference: merge
mesg command : Chapter 2, Reference: mesg
messages, email : (see email messages)
messages, error : Chapter 2, Reference: fmtmsg
Meta-key commands (emacs) : 7.3.2. Meta-key Sequences
metacharacters
for filenames
csh shell : 5.2.2. Filename Metacharacters
sh and ksh shells : 4.2.2. Filename Metacharacters
for pattern matching : 6.1. Filenames Versus Patterns
mkdir command : Chapter 2, Reference: mkdir
mkmsgs command : Chapter 2, Reference: mkmsgs
mm macros : 13. mm Macros
modes
clock, setting : Chapter 2, Reference: stty
combination, setting : Chapter 2, Reference: stty
hardware flow control : Chapter 2, Reference: stty
input : Chapter 2, Reference: stty
local : Chapter 2, Reference: stty
output : Chapter 2, Reference: stty
Telnet : Chapter 2, Reference: telnet
modules command (dbx) : Chapter 20, Reference: modules
mon.out file : Chapter 2, Reference: cc
more command : Chapter 2, Reference: more
move command (ex) : Chapter 9, Reference: move
moving
directories and files : Chapter 2, Reference: mv
files in archives : Chapter 2, Reference: ar
ms macros : 14. ms Macros
multiplexor
testing standard input for : Chapter 2, Reference: ismpx
mv command : Chapter 2, Reference: mv

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: N

n command (sed) : Chapter 10, Reference: n
N command (sed) : Chapter 10, Reference: N
nawk scripting language
Chapter 2, Reference: nawk
11.1. Command-line Syntax
(see also awk scripting language)
newform command
Chapter 2, Reference: newform
(see also cut command; paste command)
newgrp command : Chapter 2, Reference: newgrp
newgrp command (ksh, sh) : Chapter 4, Reference: newgrp
news command : Chapter 2, Reference: news
news directory, accessing : Chapter 2, Reference: news
next command (awk) : Chapter 11, Reference: next
next command (dbx) : Chapter 20, Reference: next
next command (ex) : Chapter 9, Reference: next
nexti command (dbx) : Chapter 20, Reference: nexti
nice command : Chapter 2, Reference: nice
nice command (csh) : Chapter 5, Reference: nice
nl command : Chapter 2, Reference: nl
nm command : Chapter 2, Reference: nm
nobeep shell variable : 5.3.3. Predefined Shell Variables
noclobber shell variable : 5.3.3. Predefined Shell Variables
noglob shell variable : 5.3.3. Predefined Shell Variables
nohup command : Chapter 2, Reference: nohup
nohup command (csh) : Chapter 5, Reference: nohup
nohup command (ksh, sh) : Chapter 4, Reference: nohup
nonomatch shell variable : 5.3.3. Predefined Shell Variables
notify command : Chapter 2, Reference: notify
notify command (csh) : Chapter 5, Reference: notify
notify shell variable : 5.3.3. Predefined Shell Variables
nroff program : 12. Nroff and Troff
eliminating .so requests : Chapter 2, Reference: soelim
preprocessors of : 16. Preprocessors
requests, list of : 12.4. Default Operation of Requests
null commands : Chapter 2, Reference: true
number command (ex) : Chapter 9, Reference: number
number registers
in mm macros : 13.3. Number Registers Used in mm
for ms macros
14.2. Number Registers for Page Layout
14.4. Reserved Number Register Names
in nroff/troff : 12.5.11. Number Registers
numbering lines in files : Chapter 2, Reference: nl
numbering revisions (RCS) : 18.3.4. Revision Numbering
numbers
prime factors : Chapter 2, Reference: factor
numbers, converting units of : Chapter 2, Reference: units

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: O

oawk scripting language : (see awk scripting language)
object files
generating : Chapter 2, Reference: as
removing information from : Chapter 2, Reference: strip
octal dumps, producing : Chapter 2, Reference: od
od command : Chapter 2, Reference: od
OLDPWD shell variable : 4.3.2. Built-in Shell Variables
on-line manual : (see man pages)
onintr command (csh) : Chapter 5, Reference: onintr
open command (ex) : Chapter 9, Reference: open
openwin command : Chapter 2, Reference: openwin
OpenWindows
configuring : Chapter 2, Reference: openwin
programs and utilities : Chapter 2, Reference: openwin
operators, awk : 11.5. Operators
operators, C shell : 5.4.1. Operators
OPTARGET shell variable : 4.3.2. Built-in Shell Variables
OPTIND shell variable : 4.3.2. Built-in Shell Variables
output modes, setting : Chapter 2, Reference: stty
output processing commands (sed) : 10.4.3. Input/Output Processing
ownership of files, changing : Chapter 2, Reference: chown
ownership, file
changing : Chapter 2, Reference: chgrp

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: P

p command (sed) : Chapter 10, Reference: p
P command (sed) : Chapter 10, Reference: P
pack command : Chapter 2, Reference: pack
packed files, displaying : Chapter 2, Reference: pcat
page command : (see more command)
PAGER environment variable : Chapter 2, Reference: man
pagination, nroff/troff requests for : 12.5.12. Pagination
paging files : Chapter 2, Reference: more
paragraphs, emacs commands for : 7.2.4. Paragraphs and Regions
passwd command : Chapter 2, Reference: passwd
passwd file
4.2.1. Special Files
5.2.1. Special Files
passwords
changing : Chapter 2, Reference: passwd
chkey command : Chapter 2, Reference: chkey
creating : Chapter 2, Reference: passwd
displaying information : Chapter 2, Reference: passwd
for files : Chapter 2, Reference: crypt
prompting for : Chapter 2, Reference: keylogin
paste command : Chapter 2, Reference: paste
PATH environment variable : 5.3.5. Environment Variables
PATH shell variable : 4.3.3. Other Shell Variables
path shell variable : 5.3.3. Predefined Shell Variables
pathname modifiers : 5.3.2.1. Examples Using Pathname Modifiers
pattern matching : 6. Pattern Matching
patterns, awk : 11.3. Patterns and Procedures
pcat command : Chapter 2, Reference: pcat
permissions
changing : Chapter 2, Reference: chmod
for sending email : Chapter 2, Reference: mesg
pg command : Chapter 2, Reference: pg
Pic preprocessor : 16.3. Pic
popd command (csh) : Chapter 5, Reference: popd
positioning : (see alignment/positioning)
Postscript files
adding a font to : Chapter 2, Reference: download
creating from troff files
dpost command : Chapter 2, Reference: dpost
PPID shell variable : 4.3.2. Built-in Shell Variables
pr command : Chapter 2, Reference: pr
predefined shell variables
csh shell : 5.3.3. Predefined Shell Variables
sh and ksh shells : 4.3.2. Built-in Shell Variables
preprocessors for nroff/troff system : 16. Preprocessors
preserve command (ex) : Chapter 9, Reference: preserve
prime factors : Chapter 2, Reference: factor
primitives, Pic preprocessor : 16.3.3. Primitives
print command (awk) : Chapter 11, Reference: print
print command (dbx) : Chapter 20, Reference: print
print command (ex) : Chapter 9, Reference: print
print command (ksh, sh) : Chapter 4, Reference: print
print pseudo-command (sccs) : 17.6.2. Pseudo-commands
printenv command : Chapter 2, Reference: printenv
printers, testing : Chapter 2, Reference: lptest
printf command : Chapter 2, Reference: printf
printf command (awk) : Chapter 11, Reference: printf
printing
banners : Chapter 2, Reference: banner
cancelling print requests
cancel command : Chapter 2, Reference: cancel
current system name : Chapter 2, Reference: uname
environment variable values : Chapter 2, Reference: printenv
file creation mode mask : Chapter 2, Reference: umask
files : Chapter 2, Reference: lp
from archives : Chapter 2, Reference: ar
cat command : Chapter 2, Reference: cat
lines specified : Chapter 2, Reference: tail
log files
of copied files : Chapter 2, Reference: uulog
queue
displaying : Chapter 2, Reference: lpq
removing requests from : Chapter 2, Reference: lprm
status of : Chapter 2, Reference: lpstat
sending files : Chapter 2, Reference: lpr
strings : Chapter 2, Reference: printf
system names known to uucp : Chapter 2, Reference: uuname
system usage information : Chapter 2, Reference: uptime
terminal capability : Chapter 2, Reference: tput
terminal device name : Chapter 2, Reference: tty
privileges, termination of user processes : Chapter 2, Reference: shutdown
procedures, awk : 11.3.2. Procedures
processes
controlling : (see job control)
terminating IDs : Chapter 2, Reference: kill
prof command : Chapter 2, Reference: prof
profile data
displaying
for C programming : Chapter 2, Reference: gprof
for files : Chapter 2, Reference: prof
for programs generally : Chapter 2, Reference: lprof
.profile file
4.2.1. Special Files
(see also shell variables)
programs
aborted
debugging resulting files : Chapter 2, Reference: sdb
debugging : 20. Program Debugging
displaying profile data for : Chapter 2, Reference: lprof
lexical analysis
generating : Chapter 2, Reference: lex
prompt shell variable : 5.3.3. Predefined Shell Variables
prs command (SCCS) : Chapter 17, Reference: prs
data keywords for : 17.4. Data Keywords
ps command : Chapter 2, Reference: ps
PS1..PS4 shell variables : 4.3.3. Other Shell Variables
pseudo-commands, SCCS : 17.6. sccs and Pseudo-commands
ptx command : Chapter 2, Reference: ptx
pushd command (csh) : Chapter 5, Reference: pushd
put command (ex) : Chapter 9, Reference: put
putting commands (sed) : 10.4.4. Yanking and Putting
pwd command : Chapter 2, Reference: pwd
pwd command (dbx) : Chapter 20, Reference: pwd
pwd command (ksh, sh) : Chapter 4, Reference: pwd
PWD environment variable : 5.3.5. Environment Variables
PWD shell variable : 4.3.2. Built-in Shell Variables

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: Q

q command (sed) : Chapter 10, Reference: q
queued jobs, obtaining reports on : Chapter 2, Reference: uustat
quit command (dbx) : Chapter 20, Reference: quit
quit command (ex) : Chapter 9, Reference: quit
quoting
csh shell : 5.2.3. Quoting
sh and ksh shells : 4.2.3. Quoting

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: R

r command (ksh, sh) : Chapter 4, Reference: r
r command (sed) : Chapter 10, Reference: r
rand command (awk) : Chapter 11, Reference: rand
RANDOM shell variable : 4.3.2. Built-in Shell Variables
rcp command : Chapter 2, Reference: rcp
rcs command (RCS) : Chapter 18, Reference: rcs
RCS subdirectory : 18.2. Basic Operation
RCS utility : 18. The RCS Utility
keyword substitution : 18.3.1. Keyword Substitution
revision numbering : 18.3.4. Revision Numbering
SCCS commands equivalents : 18.4. Conversion Guide for SCCS Users
rcsclean command (RCS) : Chapter 18, Reference: rcsclean
rcsdiff command (RCS)
18.2. Basic Operation
Chapter 18, Reference: rcsdiff
rcsfreeze command (RCS) : Chapter 18, Reference: rcsfreeze
RCSINIT environment variable : 18.3.7. Standard Options
rcsmerge command (RCS) : Chapter 18, Reference: rcsmerge
read command (ex) : Chapter 9, Reference: read
read command (ksh, sh) : Chapter 4, Reference: read
reading email messages : Chapter 2, Reference: mailx
readonly command (ksh, sh) : Chapter 4, Reference: readonly
recording session : Chapter 2, Reference: script
recover command (ex) : Chapter 9, Reference: recover
red command
Chapter 2, Reference: red
(see also ed command)
redirections
csh forms for : 5.2.5. Redirection Forms
sh and ksh forms for : 4.2.5. Redirection Forms
referencing arrays : 4.3.4. Arrays
regcmp command : Chapter 2, Reference: regcmp
regions, emacs commands for : 7.2.4. Paragraphs and Regions
regular expressions
compiling : Chapter 2, Reference: regcmp
lexical analysis program : Chapter 2, Reference: lex
searching files for
Chapter 2, Reference: egrep
Chapter 2, Reference: fgrep
Chapter 2, Reference: grep
for sed command addresses : 10.3.1. Pattern Addressing
rehash command (csh) : Chapter 5, Reference: rehash
relogin command : Chapter 2, Reference: relogin
remote communications (calling out) : Chapter 2, Reference: cu
remote host, connecting to : Chapter 2, Reference: rlogin
remote shell, connecting to
Chapter 2, Reference: rsh
Chapter 2, Reference: rsh
remote systems
copying files between : Chapter 2, Reference: uucp
remote systems, copying files between : Chapter 2, Reference: rcp
removing : (see deleting)
remsh command : (see rsh command)
renaming
directories and files : Chapter 2, Reference: mv
repeat command (csh) : Chapter 5, Reference: repeat
replacing files in archives : Chapter 2, Reference: ar
replacing text, metacharacters for : 6.4.1. Examples of Searching and Replacing
replay command (dbx) : Chapter 20, Reference: replay
REPLY shell variable : 4.3.2. Built-in Shell Variables
reports
on active processes : Chapter 2, Reference: ps
on system status : Chapter 2, Reference: uustat
requests, nroff/troff : 12.4. Default Operation of Requests
rerun command (dbx) : Chapter 20, Reference: rerun
reset command
Chapter 2, Reference: reset
(see also tset command)
restore command (dbx) : Chapter 20, Reference: restore
restricted shells : 4.9. Restricted Shells
return command (awk) : Chapter 11, Reference: return
return command (dbx) : Chapter 20, Reference: return
return command (ksh, sh) : Chapter 4, Reference: return
reverse linefeeds, displaying : Chapter 2, Reference: col
revision control
RCS utility : 18. The RCS Utility
SCCS utility
17. The SCCS Utility
18.4. Conversion Guide for SCCS Users
revision numbers (RCS) : 18.3.4. Revision Numbering
rewind command (ex) : Chapter 9, Reference: rewind
rksh command : Chapter 2, Reference: rksh
rksh command (ksh, sh) : 4.9. Restricted Shells
rlog command (RCS) : Chapter 18, Reference: rlog
rlogin command : Chapter 2, Reference: rlogin
rm command : Chapter 2, Reference: rm
rmdel command (SCCS) : Chapter 17, Reference: rmdel
rmdir command
Chapter 2, Reference: rmdir
(see also mkdir command)
rsh command
Chapter 2, Reference: rsh
Chapter 2, Reference: rsh
(see also sh command)
rsh command (ksh, sh) : 4.9. Restricted Shells
run command (dbx) : Chapter 20, Reference: run
running processes, core images for : Chapter 2, Reference: gcore
ruptime command : Chapter 2, Reference: ruptime
rwho command
Chapter 2, Reference: rwho
(see also who command)

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: S

s command (sed) : Chapter 10, Reference: s
sact command (SCCS) : Chapter 17, Reference: sact
save command (dbx) : Chapter 20, Reference: save
savehist shell variable : 5.3.3. Predefined Shell Variables
sccs (front end to SCCS) : 17.6. sccs and Pseudo-commands
SCCS utility : 17. The SCCS Utility
commands and psuedo-commands : 17.5. Alphabetical Summary of SCCS Commands
keywords for : 17.3. Identification Keywords
RCS commands equivalents : 18.4. Conversion Guide for SCCS Users
sccsdiff command (SCCS) : Chapter 17, Reference: sccsdiff
script command : Chapter 2, Reference: script
sdb command : Chapter 2, Reference: sdb
sdb debugger : 20.1. The Sdb Debugger
sdiff command : Chapter 2, Reference: sdiff
searching
emacs commands for : 7.2.8. Incremental Search Commands
file contents
for matching text : Chapter 2, Reference: fgrep
for newline/null sequence : Chapter 2, Reference: strings
regular expressions for
Chapter 2, Reference: egrep
Chapter 2, Reference: grep
Internet directory : Chapter 2, Reference: whois
pattern matching : 6. Pattern Matching
by pattern-matching : Chapter 2, Reference: awk
search-and-replace : 6.4.1. Examples of Searching and Replacing
searching for files : Chapter 2, Reference: find
SECONDS shell variable : 4.3.2. Built-in Shell Variables
secret keys
decrypting : Chapter 2, Reference: keylogin
deleting : Chapter 2, Reference: keylogout
secure network services
decrypting secret keys in : Chapter 2, Reference: keylogin
deleting secret keys in : Chapter 2, Reference: keylogout
sed command : Chapter 2, Reference: sed
sed editor : 10. The Sed Editor
commands for : 10.3. Syntax of Sed Commands
pattern-matching metacharacters : 6.2. Metacharacters, Listed by UNIX Program
search-and-replace examples : 6.4.1. Examples of Searching and Replacing
select command (ksh, sh) : Chapter 4, Reference: select
selecting columns from files : Chapter 2, Reference: cut
semaphore sets, removing : Chapter 2, Reference: ipcrm
sending email messages : Chapter 2, Reference: mailx
to all users : Chapter 2, Reference: wall
service grades, listing : Chapter 2, Reference: uuglist
sessions
customizing : 3.2.2. Customization of Your UNIX Session
recording : Chapter 2, Reference: script
set command (csh) : Chapter 5, Reference: set
set command (dbx) : Chapter 20, Reference: set
set command (ex) : Chapter 9, Reference: set
set command (ksh, sh) : Chapter 4, Reference: set
:set command (vi) : 8.10.1. The :set Command
setenv command (csh) : Chapter 5, Reference: setenv
setenv command (dbx) : Chapter 20, Reference: setenv
sh (Bourne shell) : 4. The Bourne Shell and Korn Shell
built-in commands, list of : 4.6. Built-in Commands (Bourne and Korn Shell)
compared to ksh and csh : 3.5. Differing Features
invoking shell : 4.8. Invoking the Shell
job control : 4.7. Job Control
setting restrictions on
Chapter 2, Reference: rsh
4.9. Restricted Shells
variables : 4.3. Variables
sh command : Chapter 2, Reference: sh
sh command (dbx) : Chapter 20, Reference: sh
SHACCT shell variable : 4.3.3. Other Shell Variables
shared memory identifiers, removing : Chapter 2, Reference: ipcrm
#! command (csh) : Chapter 5, Reference: #!
#! command (ksh, sh) : Chapter 4, Reference: #!shell
shell characters (emacs) : 7.2.12. Special Shell Characters
shell command (ex) : Chapter 9, Reference: shell
SHELL environment variable : 5.3.5. Environment Variables
shell scripts : 3.2.3. Programming
for background processes : Chapter 2, Reference: wait
job control via : Chapter 2, Reference: jsh
reading from terminal : Chapter 2, Reference: line
running : Chapter 2, Reference: lptest
SHELL shell variable : 4.3.3. Other Shell Variables
shell shell variable : 5.3.3. Predefined Shell Variables
shell variables
csh shell : 5.3.3. Predefined Shell Variables
sh and ksh shells : 4.3.2. Built-in Shell Variables
shells
invoking
4.8. Invoking the Shell
5.8. Invoking the Shell
multiple
controlling from one terminal : Chapter 2, Reference: shl
overview of : 3. The UNIX Shell: An Overview
restricted : 4.9. Restricted Shells
types (flavors) of : 3.3. Shell Flavors
shift command (csh) : Chapter 5, Reference: shift
shift command (ksh, sh) : Chapter 4, Reference: shift
shl command : Chapter 2, Reference: shl
shutdown command
Chapter 2, Reference: shutdown
(see also halt command; reboot command)
signals, tracing : Chapter 2, Reference: truss
signing on to system : Chapter 2, Reference: login
sin command (awk) : Chapter 11, Reference: sin
size command : Chapter 2, Reference: size
sleep command : Chapter 2, Reference: sleep
.so requests, eliminating in nroff or troff files : Chapter 2, Reference: soelim
soelim command : Chapter 2, Reference: soelim
Solaris 2.0 : 1.1. Merging the Traditions
generating index for : Chapter 2, Reference: ptx
sort command
Chapter 2, Reference: sort
(see also comm command; join command; uniq command)
sorting files : Chapter 2, Reference: tsort
joining lines of sorted files : Chapter 2, Reference: join
removing duplicate lines : Chapter 2, Reference: uniq
source command (csh) : Chapter 5, Reference: source
source command (dbx) : Chapter 20, Reference: source
source command (ex) : Chapter 9, Reference: source
source files, sending : Chapter 2, Reference: uuto
spacing : (see whitespace)
spell command : Chapter 2, Reference: spell
split command : Chapter 2, Reference: split
split command (awk) : Chapter 11, Reference: split
splitting files : Chapter 2, Reference: csplit
sprintf command (awk) : Chapter 11, Reference: sprintf
sqrt command (awk) : Chapter 11, Reference: sqrt
srand command (awk) : Chapter 11, Reference: srand
srchtxt command : Chapter 2, Reference: srchtxt
standard input
copying : Chapter 2, Reference: tr
standard input, copying : Chapter 2, Reference: tee
state, revision (RCS) : 18.3.6. Specifying States
status command (dbx) : Chapter 20, Reference: status
status shell variable : 5.3.3. Predefined Shell Variables
step command (dbx) : Chapter 20, Reference: step
stepi command (dbx) : Chapter 20, Reference: stepi
stop command (csh) : Chapter 5, Reference: stop
stop command (dbx) : Chapter 20, Reference: stop
stop command (ksh, sh) : Chapter 4, Reference: stop
stopi command (dbx) : Chapter 20, Reference: stopi
stream editors : Chapter 2, Reference: sed
strings
printing : Chapter 2, Reference: printf
processing, nroff/troff requests for : 12.5.10. Macro and String Processing
strings command : Chapter 2, Reference: strings
strip command : Chapter 2, Reference: strip
stty command : Chapter 2, Reference: stty
su command : Chapter 2, Reference: su
sub command (awk) : Chapter 11, Reference: sub
substitute command (ex) : Chapter 9, Reference: substitute
substr command (awk) : Chapter 11, Reference: substr
sum command : Chapter 2, Reference: sum
suspend command (csh) : Chapter 5, Reference: suspend
suspend command (ksh, sh) : Chapter 4, Reference: suspend
SVR4 (System V Release 4) : 1.1. Merging the Traditions
switch command (csh) : Chapter 5, Reference: switch
symbol cross-references
Chapter 2, Reference: cscope
Chapter 2, Reference: cxref
symbol tables, printing : Chapter 2, Reference: nm
system calls, tracing : Chapter 2, Reference: truss
system command (awk) : Chapter 11, Reference: system
system dictionary, adding to : Chapter 2, Reference: spell
system name, current
current system name : Chapter 2, Reference: uname
system usage information
Chapter 2, Reference: time
Chapter 2, Reference: timex
Chapter 2, Reference: w
logged-in users : Chapter 2, Reference: ruptime
printing : Chapter 2, Reference: uptime
System V Release 4 (SVR4) : 1.1. Merging the Traditions
system variables, awk : 11.4. Awk System Variables

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: T

t command (ex) : Chapter 9, Reference: t
t command (sed) : Chapter 10, Reference: t
tab stops, setting : Chapter 2, Reference: tabs
tables
converting files into : Chapter 2, Reference: yacc
symbol tables, printing : Chapter 2, Reference: nm
tables, formatting in nroff/troff : 16.1. Tbl
tabs command : Chapter 2, Reference: tabs
tabs, nroff/troff requests for : 12.5.13. Tabs
tag command (ex) : Chapter 9, Reference: tag
tail command : Chapter 2, Reference: tail
talk command : Chapter 2, Reference: talk
tape files, copying/restoring
Chapter 2, Reference: cpio
Chapter 2, Reference: tar
tar command : Chapter 2, Reference: tar
targets, updating : Chapter 2, Reference: make
Tbl preprocessor : 16.1. Tbl
tee command : Chapter 2, Reference: tee
tell pseudo-command (sccs) : 17.6.2. Pseudo-commands
telnet command : Chapter 2, Reference: telnet
Telnet modes : Chapter 2, Reference: telnet
TERM environment variable : 5.3.5. Environment Variables
TERM shell variable : 4.3.3. Other Shell Variables
term shell variable : 5.3.3. Predefined Shell Variables
TERMCAP environment variable : 5.3.5. Environment Variables
terminals
capability of : Chapter 2, Reference: tput
clearing displays : Chapter 2, Reference: clear
clearning settings : Chapter 2, Reference: reset
device name, printing : Chapter 2, Reference: tty
resetting window layers : Chapter 2, Reference: jterm
setting modes : Chapter 2, Reference: tset
setting options : Chapter 2, Reference: stty
testing : Chapter 2, Reference: lptest
terminating process IDs : Chapter 2, Reference: kill
termination of user processes : Chapter 2, Reference: shutdown
termination status for background processes : Chapter 2, Reference: wait
test command : Chapter 2, Reference: test
test command (ksh, sh) : Chapter 4, Reference: test
text
ASCII character set : 21. ASCII Character Set
pattern matching : 6. Pattern Matching
text editors
7. The Emacs Editor
(see also under specific editors)
pattern-matching metacharacters for : 6.2. Metacharacters, Listed by UNIX Program
recovering files after crash : Chapter 2, Reference: vi
screen-oriented : Chapter 2, Reference: vi
vedit editor : Chapter 2, Reference: vedit
text files, editing : (see text editors)
text formatting
me macros : 15. me Macros
mm macros : 13. mm Macros
ms macros : 14. ms Macros
nroff and troff programs : 12. Nroff and Troff
nroff/troff preprocessors : 16. Preprocessors
time command : Chapter 2, Reference: time
time command (csh) : Chapter 5, Reference: time
time command (ksh, sh) : Chapter 4, Reference: time
time shell variable : 5.3.3. Predefined Shell Variables
times command (ksh, sh) : Chapter 4, Reference: times
timex command : Chapter 2, Reference: timex
TMOUT shell variable : 4.3.3. Other Shell Variables
tolower command (awk) : Chapter 11, Reference: tolower
touch command : Chapter 2, Reference: touch
toupper command (awk) : Chapter 11, Reference: toupper
tput command : Chapter 2, Reference: tput
tr command : Chapter 2, Reference: tr
trace command (dbx) : Chapter 20, Reference: trace
tracei command (dbx) : Chapter 20, Reference: tracei
tracing signals : Chapter 2, Reference: truss
transposition commands (emacs) : 7.2.6. Transposition Commands
trap command (ksh, sh) : Chapter 4, Reference: trap
troff files
converting to Postscript files
dpost command : Chapter 2, Reference: dpost
troff program : 12. Nroff and Troff
eliminating .so requests : Chapter 2, Reference: soelim
preprocessors of : 16. Preprocessors
requests, list of : 12.4. Default Operation of Requests
true command : Chapter 2, Reference: true
truss command : Chapter 2, Reference: truss
tset command : Chapter 2, Reference: tset
tsort command : Chapter 2, Reference: tsort
tty command : Chapter 2, Reference: tty
type command (ksh, sh) : Chapter 4, Reference: type
typeset command (ksh, sh) : Chapter 4, Reference: typeset

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: U

ulimit command (ksh, sh) : Chapter 4, Reference: ulimit
umask command
Chapter 2, Reference: umask
(see also chmod command)
umask command (csh) : Chapter 5, Reference: umask
umask command (ksh, sh) : Chapter 4, Reference: umask
unabbreviate command (ex) : Chapter 9, Reference: unabbreviate
unalias command (csh) : Chapter 5, Reference: unalias
unalias command (dbx) : Chapter 20, Reference: unalias
unalias command (ksh, sh) : Chapter 4, Reference: unalias
uname command : Chapter 2, Reference: uname
uncompress command : Chapter 2, Reference: uncompress
uncompressing files
Chapter 2, Reference: uncompress
Chapter 2, Reference: zcat
undisplay command (dbx) : Chapter 20, Reference: undisplay
undo command (ex) : Chapter 9, Reference: undo
undoing, emacs commands for : 7.2.5. Stopping and Undoing Commands
unedit pseudo-command (sccs) : 17.6.2. Pseudo-commands
unget command (SCCS) : Chapter 17, Reference: unget
unhash command (csh) : Chapter 5, Reference: unhash
uniq command : Chapter 2, Reference: uniq
units command : Chapter 2, Reference: units
units of measurements (nroff/troff) : 12.3.2. Specifying Measurements
Unix
bundling software packages : 1.2. Bundling
shells : (see shells)
versions of : 1.1. Merging the Traditions
unlimit command (csh) : Chapter 5, Reference: unlimit
unmap command (ex) : Chapter 9, Reference: unmap
unpack command
Chapter 2, Reference: unpack
(see also pack command; pcat command)
unset : Chapter 4, Reference: unset
unset command (csh) : Chapter 5, Reference: unset
unset command (dbx) : Chapter 20, Reference: unset
unsetenv command (csh) : Chapter 5, Reference: unsetenv
until : Chapter 4, Reference: until
up command (dbx) : Chapter 20, Reference: up
uppercase : (see case)
uptime command : Chapter 2, Reference: uptime
usage information
Chapter 2, Reference: time
Chapter 2, Reference: timex
Chapter 2, Reference: w
use command (dbx) : Chapter 20, Reference: use
USER environment variable : 5.3.5. Environment Variables
user shell variable : 5.3.3. Predefined Shell Variables
users
displaying data about : Chapter 2, Reference: finger
groups
displaying : Chapter 2, Reference: groups
IDs
displaying : Chapter 2, Reference: id
information on those logged in : Chapter 2, Reference: w
logged-in
displaying list
Chapter 2, Reference: users
Chapter 2, Reference: who
displaying system usage : Chapter 2, Reference: ruptime
report on : Chapter 2, Reference: rwho
permissions
changing : Chapter 2, Reference: mesg
sending email messages to all : Chapter 2, Reference: wall
terminating processes of : Chapter 2, Reference: shutdown
usernames, printing : Chapter 2, Reference: whoami
users command : Chapter 2, Reference: users
uucp command
Chapter 2, Reference: uucp
(see also uustat command)
uucp requests
cancelling : Chapter 2, Reference: uustat
obtaining information on : Chapter 2, Reference: uustat
uudecode command : Chapter 2, Reference: uudecode
uudecode, uuencode commands : Chapter 2, Reference: uudecode
uuencode command : Chapter 2, Reference: uuencode
uuglist command : Chapter 2, Reference: uuglist
uulog command
Chapter 2, Reference: uulog
(see also tail command)
uuname command
Chapter 2, Reference: uuname
(see also uucp command)
uupick command
Chapter 2, Reference: uupick
(see also uuto command)
uustat command
Chapter 2, Reference: uustat
(see also uucp command)
uuto command
Chapter 2, Reference: uuto
(see also uupick command)
uux command : Chapter 2, Reference: uux

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: V

v command (ex) : Chapter 9, Reference: v
vacation command : Chapter 2, Reference: vacation
val command (SCCS) : Chapter 17, Reference: val
variable modifiers, C shell : 5.3.2. Variable Modifiers
variable substitution
4.3.1. Variable Substitution
5.3.1. Variable Substitution
variables
awk system variables : 11.4. Awk System Variables
csh shell : 5.3. Variables
sh and ksh shells : 4.3. Variables
vc command (obsolete) : Chapter 2, Reference: vc
vedit editor : Chapter 2, Reference: vedit
verbose shell variable : 5.3.3. Predefined Shell Variables
version command (ex) : Chapter 9, Reference: version
vertical alignment : (see alignment/positioning)
vertical spacing : (see whitespace)
vi editor
Chapter 2, Reference: vi
8. The Vi Editor
(see also ex editor)
ex commands in : 9.1. Syntax of Ex Commands
pattern-matching metacharacters : 6.2. Metacharacters, Listed by UNIX Program
:set command : 8.10.1. The :set Command
view command : (see vi editor)
visual command (ex) : Chapter 9, Reference: visual
VISUAL shell variable : 4.3.3. Other Shell Variables

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: W

w command : Chapter 2, Reference: w
w command (sed) : Chapter 10, Reference: w
wait command : Chapter 2, Reference: wait
wait command (csh) : Chapter 5, Reference: wait
wait command (ksh, sh) : Chapter 4, Reference: wait
wall command : Chapter 2, Reference: wall
wc command : Chapter 2, Reference: wc
what command (SCCS) : Chapter 17, Reference: what
whatis command : Chapter 2, Reference: whatis
whatis command (dbx) : Chapter 20, Reference: whatis
when command (dbx) : Chapter 20, Reference: when
whence command (ksh, sh) : Chapter 4, Reference: whence
where command (dbx) : Chapter 20, Reference: where
whereis command (dbx) : Chapter 20, Reference: whereis
which command : Chapter 2, Reference: which
which command (dbx) : Chapter 20, Reference: which
while command (awk) : Chapter 11, Reference: while
while command (csh) : Chapter 5, Reference: while
while command (ksh, sh) : Chapter 4, Reference: while
whitespace
nroff/troff requests for : 12.5.15. Vertical Spacing
whitespace, nroff/troff requests for : 12.5.13. Tabs
who command : Chapter 2, Reference: who
whoami command
Chapter 2, Reference: whoami
(see also logname command)
whois command : Chapter 2, Reference: whois
wildcards
filename metacharacters
csh shell : 5.2.2. Filename Metacharacters
filename metachracters
sh and ksh shells : 4.2.2. Filename Metacharacters
windows
asynchronous
managing : Chapter 2, Reference: layers
default
setting size : Chapter 2, Reference: vi
emacs, commands for : 7.2.11. Window Commands
size
printing : Chapter 2, Reference: jwin
setting : Chapter 2, Reference: stty
testing standard input for : Chapter 2, Reference: ismpx
word abbreviations (emacs) : 7.2.9. Word Abbreviation Commands
word substitution (csh) : 5.5.3. Word Substitution
wordlist files : Chapter 2, Reference: spell
words, counting in files : Chapter 2, Reference: wc
wq command (ex) : Chapter 9, Reference: wq
write command : Chapter 2, Reference: write
write command (ex) : Chapter 9, Reference: write
writing to standard output : Chapter 2, Reference: echo

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: X

x command (sed) : Chapter 10, Reference: x
xargs command : Chapter 2, Reference: xargs
xit command (ex) : Chapter 9, Reference: xit

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: Y

y command (sed) : Chapter 10, Reference: y
yacc command : Chapter 2, Reference: yacc
yank command (ex) : Chapter 9, Reference: yank
yanking commands (sed) : 10.4.4. Yanking and Putting

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: Z

z command (ex) : Chapter 9, Reference: z
zcat command : Chapter 2, Reference: zcat

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Index: Symbols and Numbers

& command (ex) : Chapter 9, Reference: &
< > command (ex) : Chapter 9, Reference: < >
@ command (csh) : Chapter 5, Reference: @
! command (ex) : Chapter 9, Reference: !
[[ ]] command (ksh) : Chapter 4, Reference: [[ ]]
: command (csh)
csh shell : Chapter 5, Reference: :
: command (ksh, sh)
ksh and sh shells : Chapter 4, Reference: :
: command (sed) : Chapter 10, Reference: :
= command (ex) : Chapter 9, Reference: =
= command (sed) : Chapter 10, Reference: =
# command (csh) : Chapter 5, Reference: #
# command (ksh, sh) : Chapter 4, Reference: #
#! command (csh) : Chapter 5, Reference: #!
#! command (ksh, sh) : Chapter 4, Reference: #!shell
~ command (ex) : Chapter 9, Reference: ~

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Copyright © 1998 O'Reilly & Associates, Inc. All Rights Reserved.


Reference: admin

UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: 2. UNIX Commands Chapter 2
UNIX Commands 		Next: Reference: apropos

admin

admin [options] files

An SCCS command. See Section 17.

Previous: 2. UNIX Commands | UNIX in a Nutshell: System V Edition | Next: Reference: apropos
2. UNIX Commands | Book Index | Reference: apropos


Reference: apropos

Previous: Reference: admin Chapter 2
UNIX Commands 		Next: Reference: ar

apropos

/usr/ucb/apropos keywords

Look up one or more keywords in the on-line manual pages. Same as man -k. See also whatis.

Previous: Reference: admin | UNIX in a Nutshell: System V Edition | Next: Reference: ar
Reference: admin | Book Index | Reference: ar


Reference: ar

Previous: Reference: apropos Chapter 2
UNIX Commands 		Next: Reference: as

ar

ar [-V] key [args] [posname] archive  [files]

Maintain a group of files that are combined into a file archive. Used most commonly to create and update library files as used by the link editor (ld). Only one key letter may be used, but each can be combined with additional args (with no separations between). posname is the name of a file in archive. When moving or replacing files, you can specify that they be placed before or after posname. See lorder for another example. -V prints the version number of ar on standard error.

Key

d

Delete files from archive.

m

Move files to end of archive.

p

Print files in archive.

q

Append files to archive.

r

Replace files in archive.

t

List the contents of archive or list the named files.

x

Extract contents from archive or only the named files.

Args

a

Use with r or m to place files in the archive after posname.

b

Same as a but before posname.

c

Create archive silently.

i

Same as b.

l

Place temporary files in local directory rather than /tmp (SVR3 only).

s

Force regeneration of archive symbol table (useful after running strip or mcs).

u

Use with r to replace only files that have changed since being put in archive.

v

Verbose; print a description.

Example

Replace mylib.a with object files from the current directory:

ar r mylib.a `ls *.o`

Previous: Reference: apropos | UNIX in a Nutshell: System V Edition | Next: Reference: as
Reference: apropos | Book Index | Reference: as


Reference: as

Previous: Reference: ar Chapter 2
UNIX Commands 		Next: Reference: at

as

as [options] files

Generate an object file from each specified assembly language source file. Object files have the same root name as source files but replace the .s suffix with .o. There may be additional system-specific options. See also dis.

Options

-m

Run m4 on file.

-n

Turn off optimization of long/short addresses.

-o objfile

Place output in object file objfile (default is file.o).

-Qc

Put the assembler's version number in the object file (when c = y); default is not to put it (c = n).

-R

Remove file upon completion.

-T

Force obsolete assembler directives to be obeyed.

-V

Display the version number of the assembler.

-Y [key,] dir

Search directory dir for the m4 preprocessor (if key is m), for the file containing predefined macros (if key is d), or for both (if key is omitted).

Previous: Reference: ar | UNIX in a Nutshell: System V Edition | Next: Reference: at
Reference: ar | Book Index | Reference: at


Reference: at

Previous: Reference: as Chapter 2
UNIX Commands 		Next: Reference: atq

at

at options1 time [date] [+ increment]
at options2 [jobs]

Execute commands entered on standard input at a specified time and optional date. (See also batch.) End input with EOF. time can be formed either as a numeric hour (with optional minutes and modifiers) or as a keyword. date can be formed either as a month and date, as a day of the week, or as a special keyword. increment is a positive integer followed by a keyword. See below for details.

Options1

-f file

Execute commands listed in file.

-m

Send mail to user after job is completed.

Options2

-l

Report all jobs that are scheduled for the invoking user or, if jobs are specified, report only for those. See also atq.

-r

Remove specified jobs that were previously scheduled. To remove a job, you must be a privileged user or the owner of the job. Use -l first to see the list of scheduled jobs. See also atrm.

Time

hh:mm [modifiers]

Hours can have one digit or two (a 24-hour clock is assumed by default); optional minutes can be given as one or two digits; the colon can be omitted if the format is h, hh, or hhmm; e.g., valid times are 5, 5:30, 0530, 19:45. If modifier am or pm is added, time is based on a 12-hour clock. If the keyword zulu is added, times correspond to Greenwich Mean Time.

midnight | noon | now

Use any one of these keywords in place of a numeric time. now must be followed by an increment.

Date

month num[, year]

month is one of the 12 months, spelled out or abbreviated to their first three letters; num is the calendar date of the month; year is the four-digit year. If the given month occurs before the current month, at schedules that month next year.

day

One of the seven days of the week, spelled out or abbreviated to their first three letters.

today | tomorrow

Indicate the current day or the next day. If date is omitted, at schedules today when the specified time occurs later than the current time; otherwise, at schedules tomorrow.

Increment

Supply a numeric increment if you want to specify an execution time or day relative to the current time. The number should precede any of the keywords minute, hour, day, week, month, or year (or their plural forms). The keyword next can be used as a synonym of + 1.

Examples

Note that the first two commands are equivalent:

at 1945 pm December 9
at 7:45pm Dec 9
at 3 am Saturday
at now + 5 hours
at noon next day

Previous: Reference: as | UNIX in a Nutshell: System V Edition | Next: Reference: atq
Reference: as | Book Index | Reference: atq


Reference: atq

Previous: Reference: at Chapter 2
UNIX Commands 		Next: Reference: atrm

atq

atq [options] [users]

Print jobs created by the at command which are still in the queue. Normally, jobs are sorted by the order in which they will execute. Specify the users whose jobs you want to check. If no users are specified, the default is to display all jobs if you're a privileged user; otherwise, only your jobs are displayed.

Options

-c

Sort the queue according to the time the at command was given.

-n

Print only the total number of jobs in queue.

Previous: Reference: at | UNIX in a Nutshell: System V Edition | Next: Reference: atrm
Reference: at | Book Index | Reference: atrm


Reference: atrm

Previous: Reference: atq Chapter 2
UNIX Commands 		Next: Reference: awk

atrm

atrm [options] [users | jobIDs]

Remove jobs queued with at that match the specified jobIDs. A privileged user may also specify the users whose jobs are to be removed.

Options

-a

Remove all jobs belonging to the current user. (A privileged user can remove all jobs.)

-f

Remove jobs unconditionally, suppressing all information regarding removal.

-i

Prompt for y (remove the job) or n (do not remove).

Previous: Reference: atq | UNIX in a Nutshell: System V Edition | Next: Reference: awk
Reference: atq | Book Index | Reference: awk


Reference: awk

Previous: Reference: atrm Chapter 2
UNIX Commands 		Next: Reference: banner

awk

awk [options] [program] [var=value ...] [files]

Use the pattern-matching program to modify the specified files. awk has been replaced by nawk (there's also a GNU version called gawk). program instructions have the general form:

pattern { procedure }

pattern and procedure are each optional. When specified on the command line, program must be enclosed in single quotes to prevent the shell from interpreting its special symbols. Any variables specified in program can be assigned an initial value by using command-line arguments of the form var=value. See Section 11 for more information (including examples) on awk.

Options

-f file

Use program instructions contained in file, instead of specifying program on the command line.

-Fc

Treat input file as fields separated by character c. Default input field separator is space or tab.

Previous: Reference: atrm | UNIX in a Nutshell: System V Edition | Next: Reference: banner
Reference: atrm | Book Index | Reference: banner


Reference: banner

Previous: Reference: awk Chapter 2
UNIX Commands 		Next: Reference: basename

banner

banner characters

Print characters as a poster on the standard output. Each word supplied must contain ten characters or less.

Previous: Reference: awk | UNIX in a Nutshell: System V Edition | Next: Reference: basename
Reference: awk | Book Index | Reference: basename


Reference: basename

Previous: Reference: banner Chapter 2
UNIX Commands 		Next: Reference: batch

basename

basename pathname [suffix]

Given a pathname, strip the path prefix and leave just the filename, which is printed on standard output. If specified, a filename suffix (e.g., .c) is removed also. basename is typically invoked via command substitution (` `) to generate a filename. See also dirname.

Example

Given the following fragment from a Bourne shell script:

prog_name="`basename $0`"
echo "$prog_name: QUITTING: can't open $ofile"/
     1>&2 ; exit 1

If the script is called do_it, then the following message would be printed on standard error:

do_it: QUITTING: can't open output_file

Previous: Reference: banner | UNIX in a Nutshell: System V Edition | Next: Reference: batch
Reference: banner | Book Index | Reference: batch


Reference: batch

Previous: Reference: basename Chapter 2
UNIX Commands 		Next: Reference: bc

batch

batch

Execute commands entered on standard input. End with EOF. Unlike at, which will execute commands at a specific time, batch executes commands one after another (waiting for each one to complete). This avoids the high system load caused by running several background jobs at once. See also at.

Example

batch
sort in > out
troff -ms bigfile
EOF

Previous: Reference: basename | UNIX in a Nutshell: System V Edition | Next: Reference: bc
Reference: basename | Book Index | Reference: bc


Reference: bc

Previous: Reference: batch Chapter 2
UNIX Commands 		Next: Reference: bdiff

bc

bc [options] [files]

Interactively perform arbitrary-precision arithmetic or convert numbers from one base to another. Input can be taken from files or read from the standard input. To exit, type quit or EOF.

Options

-c

Do not invoke dc; compile only. (Since bc is a preprocessor for dc, bc normally invokes dc.)

-l

Make available functions from the math library.

bc is a language (and compiler) whose syntax resembles that of C. bc consists of identifiers, keywords, and symbols, which are briefly described below. Examples follow at end.

Identifiers

An identifier is a single character, consisting of the lowercase letters a-z. Identifiers are used as names for variables, arrays, and functions. Within the same program you may name a variable, an array, and a function using the same letter. The following identifiers would not conflict:

x

Variable x.

x[i]

Element i of array x. i can range from 0 to 2047 and can also be an expression.

x(y,z)

Call function x with parameters y and z.

Input-output keywords

ibase, obase, and scale store a value. Typing them on a line by themselves displays their current value. More commonly, you would change their values through assignment. Letters A-F are treated as digits whose values are 10-15.

ibase = n

Numbers that are input (e.g., typed) are read as base n (default is 10).

obase = n

Numbers displayed are in base n (default is 10). Note: Once ibase has been changed from 10, use digit "A" to restore ibase or obase to decimal.

scale = n

Display computations using n decimal places (default is 0, meaning that results are truncated to integers). scale is normally used only for base-10 computations.

Statement keywords

A semicolon or a newline separates one statement from another. Curly braces are needed only when grouping multiple statements.

if (rel-expr) {statements}

Do one or more statements if relational expression rel-expr is true; for example:

if(x==y) i = i + 1.

while (rel-expr) {statements}

Repeat one or more statements while rel-expr is true; for example:

while(i>0) {p = p*n; q = a/b; i = i-1}

for (expr1;rel-expr;expr2) {statements}

Similar to while; for example, to print the first 10 multiples of 5, you could type:

for(i=1; i<=10; i++) i*5

break

Terminate a while or for statement.

Function keywords

define j(k) {

Begin the definition of function j having a single argument k. Additional arguments are allowed, separated by commas. Statements follow on successive lines. End with a }.

auto x, y

Set up x and y as variables local to a function definition, initialized to 0 and meaningless outside the function. Must appear first.

return(expr)

Pass the value of expression expr back to the program. Return 0 if (expr) is left off. Used in function definitions.

sqrt(expr)

Compute the square root of expression expr.

length(expr)

Compute how many digits are in expr.

scale(expr)

Same, but count only digits to the right of the decimal point.

Math library functions

These are available when bc is invoked with -l. Library functions set scale to 20.

s(angle)

Compute the sine of angle, a constant or expression in radians.

c(angle)

Compute the cosine of angle, a constant or expression in radians.

a(n)

Compute the arctangent of n, returning an angle in radians.

e(expr)

Compute e to the power of expr.

l(expr)

Compute natural log of expr.

j(n, x)

Compute Bessel function of integer order n.

Operators

These consist of operators and other symbols. Operators can be arithmetic, unary, assignment, or relational.

arithmetic

+ - * / % ^

unary

- ++ --

assignment

=+ =- =* =/ =% =^ =

relational

< <= > >= == !=

Other symbols

/* */

Enclose comments.

( )

Control the evaluation of expressions (change precedence). Can also be used around assignment statements to force the result to print.

{ }

Used to group statements.

[ ]

Array index.

"text"

Use as a statement to print text.

Examples

Note below that when you type some quantity (a number or expression), it is evaluated and printed, but assignment statements produce no display.

ibase = 8	Octal input.
20		Evaluate this octal number.
16		Terminal displays decimal value.
obase = 2	Display output in base 2 instead of base 10.
20		Octal input.
10000	Terminal now displays binary value.
ibase = A	Restore base 10 input.
scale = 3	Truncate results to 3 places.
8/7		Evaluate a division.
1.001001000	Oops!  Forgot to reset output base to 10.
obase=10	Input is decimal now, so "A" isn't needed.
8/7
1.142	Terminal displays result (truncated).

The following lines show the use of functions:

define p(r,n){    Function p uses two arguments.
  auto v          v is a local variable.
  v = r^n         r raised to the n power.
  return(v)}      Value returned.

scale=5
x=p(2.5,2)        x = 2.5 ^ 2
x                 Print value of x.
6.25
length(x)         Number of digits.
3
scale(x)          Number of places right of decimal point.
2

Previous: Reference: batch | UNIX in a Nutshell: System V Edition | Next: Reference: bdiff
Reference: batch | Book Index | Reference: bdiff


Reference: bdiff

Previous: Reference: bc Chapter 2
UNIX Commands 		Next: Reference: bfs

bdiff

bdiff file1 file2 [options]

Compare file1 with file2 and report the differing lines. bdiff splits the files and then runs diff, allowing it to act on files that would normally be too large to handle. bdiff reads standard input if one of the files is - . See also diff.

Options

n

Split each file into n-line segments (default is 3500). This option must be listed first.

-s

Suppress error messages from bdiff (but not from diff).

Previous: Reference: bc | UNIX in a Nutshell: System V Edition | Next: Reference: bfs
Reference: bc | Book Index | Reference: bfs


Reference: bfs

Previous: Reference: bdiff Chapter 2
UNIX Commands 		Next: Reference: cal

bfs

bfs [option] file

Big file scanner. Read a large file, using ed-like syntax. This command is more efficient than ed for scanning very large files because the file is not read into a buffer. Files can be up to 1024K bytes. bfs can be used to view a large file and identify sections to be divided with csplit. Not too useful.

Option

-

Do not print the file size.

Previous: Reference: bdiff | UNIX in a Nutshell: System V Edition | Next: Reference: cal
Reference: bdiff | Book Index | Reference: cal


Reference: cal

Previous: Reference: bfs Chapter 2
UNIX Commands 		Next: Reference: calendar

cal

cal [[month] year]

With no arguments, print a calendar for the current month. Otherwise, print either a 12-month calendar (beginning with January) for the given year or a one-month calendar of the given month and year. month ranges from 1 to 12. year ranges from 1 to 9999.

Examples

cal 12 1994
cal 1994 > year_file

Previous: Reference: bfs | UNIX in a Nutshell: System V Edition | Next: Reference: calendar
Reference: bfs | Book Index | Reference: calendar


Reference: calendar

Previous: Reference: cal Chapter 2
UNIX Commands 		Next: Reference: cancel

calendar

calendar [option]

Read your calendar file and display all lines that contain the current date. The calendar file is like a memo board. You create the file and add entries like the following:

5/4     meeting with design group at 2 pm
may 6   pick up anniversary card on way home

When you run calendar on May 4, the first line is displayed. calendar can be automated by using crontab or at or by including it in your startup files .profile or .cshrc.

Option

-

Allow a privileged user to invoke calendar for all users, searching each user's login directory for a file named calendar. Entries that match are sent to a user via mail.

Previous: Reference: cal | UNIX in a Nutshell: System V Edition | Next: Reference: cancel
Reference: cal | Book Index | Reference: cancel


Reference: cancel

Previous: Reference: calendar Chapter 2
UNIX Commands 		Next: Reference: cat

cancel

cancel [options] [printer]

Cancel print requests made with lp. The request can be specified by its ID, by the printer on which it is currently printing, or by the username associated with the request (only privileged users can cancel another user's print requests). Use lpstat to determine either the id or the printer to cancel.

Options

id

Cancel print request id.

-u user

Cancel request associated with user.

Previous: Reference: calendar | UNIX in a Nutshell: System V Edition | Next: Reference: cat
Reference: calendar | Book Index | Reference: cat


Reference: cat

Previous: Reference: cancel Chapter 2
UNIX Commands 		Next: Reference: cb

cat

cat [options] [files]

Read one or more files and print them on standard output. Read standard input if no files are specified or if - is specified as one of the files; end input with EOF. You can use the > operator to combine several files into a new file; use >> to append files to an existing file.

Options

-e

Print a $ to mark the end of each line. Must be used with -v.

-s

Suppress messages about nonexistent files. (Note: In the BSD version, -s squeezes out extra blank lines.)

-t

Print each tab as ^I and each form feed as ^L. Must be used with -v.

-u

Print output as unbuffered (default is buffered in blocks or screen lines).

-v

Display control characters and other nonprinting characters.

Examples

cat ch1		Display a file.
cat ch1 ch2 ch3 > all		Combine files.
cat note5 >> notes		Append to a file.
cat > temp1		Create file at terminal; end with EOF.
cat > temp2 << STOP		Create file at terminal; end with STOP.

Previous: Reference: cancel | UNIX in a Nutshell: System V Edition | Next: Reference: cb
Reference: cancel | Book Index | Reference: cb


Reference: cb

Previous: Reference: cat Chapter 2
UNIX Commands 		Next: Reference: cc

cb

cb [options] [files]

C program "beautifier" that formats files using proper C programming structure.

Options

-j

Join split lines.

-l length

Split lines longer than length.

-s

Standardize code to style of Kernighan and Ritchie in The C Programming Language.

-V

Print the version of cb on standard error.

Example

cb -l 70 calc.c > calc_new.c

Previous: Reference: cat | UNIX in a Nutshell: System V Edition | Next: Reference: cc
Reference: cat | Book Index | Reference: cc


Reference: cc

Previous: Reference: cb Chapter 2
UNIX Commands 		Next: Reference: cd

cc

cc [options] files

Compile one or more C source files (file.c), assembler source files (file.s), or preprocessed C source files (file.i). cc automatically invokes the link editor ld (unless -c is supplied). In some cases, cc generates an object file having a .o suffix and a corresponding root name. By default, output is placed in a.out. cc accepts additional system-specific options. Note: This command runs the ANSI C compiler; use /usr/bin/cc if you want to run the compiler for Kernighan and Ritchie's C.

Options

-#

Show when each compiler tool is invoked. Solaris 2.0 only.

-A name[(tokens)]

Supply an #assert directive, assigning name with optional tokens as parameters.

-A -

Ignore predefined assertions and macros.

-B mode

Use with one or more -l options to tell ld what type of library files to search. When mode is dynamic, libraries are shared, meaning that library files ending in both .so and .a are searched. When mode is static, only .a files are searched. To restore the previous search mode for additional -l options, supply -B again and change its mode.

-C

Do not strip comments during preprocessing.

-c

Suppress link editing and keep any object files that were produced.

-D name[=def]

Supply a #define directive, defining name to be def or, if no def is given, the value 1.

-dc

Tell ld to link dynamically when c is y (the default) or to link statically when c is n.

-dalign

Produce double load/store instructions to improve performance. Solaris 2.0 only.

-E

Run only the macro preprocessor, sending results to standard output.

-fast

Use cc options that give fastest compilation. Solaris 2.0 only.

-flags

Briefly describe available options. Solaris 2.0 only.

-fnonstd

Produce SIGFPE signals for floating-point overflows and division by zero. Solaris 2.0 only.

-fsingle

Evaluate float expressions as single-precision. Solaris 2.0 only.

-G

Produce a shared object instead of a dynamically linked executable.

-g

Generate more symbol-table information needed for debuggers dbx (Solaris) or sdb (SVR4).

-H

List (on standard error) the pathnames of header files used in C files.

-I dir

Search for include files in directory dir (in addition to standard locations). Supply a -I for each new dir to be searched.

-K word

If word is PIC, produce position-independent code; if word is minabi, compile with the minimum dynamic linking that preserves ABI conformance.

-keeptmp

Don't delete temporary files. Solaris 2.0 only.

-L dir

Like -I, but search dir for library archives.

-l name

Link source file with library files lib name.so or lib name.a.

-O

Optimize object code (produced by .c or .i files).

-o file

Send object output to file instead of to a.out.

-P

Run only the preprocessor and place the result in file.i.

-p

Generate benchmark code to count the times each routine is called. File mon.out is created, so prof can later be used to produce an execution profile.

-Qc

List in the output (c = y) or do not list (c = n) information about the compilation tools invoked. Default is to list.

-ql

Invoke the basic block analyzer and produce code to count the times each source line is executed. Use lprof to list the counts.

-qp

Same as -p.

-S

Compile (and optimize, if -O is supplied), but don't assemble or link; assembler output is placed in file.s.

-U name

Remove definition of name, as if through an #undef directive.

-V

Print version information for compiler tools.

-v

Check semantics strictly, and allow some lint constructs to work.

-W[p02abl],arg1[,arg2...]

Each comma-separated argument is a command-line token (option, parameter) from cc. -W hands off these arguments to allow separate processing by a particular compiler tool. p or 0 specifies the compiler; 2, optimizer; b, basic block analyzer; a, assembler; l, link editor.

-Xc

Set c as the level of ANSI C compliance:

t

Transition (default). Source code must comply with pre-ANSI features.

a

ANSI. Code must comply with ANSI features, but doesn't warn about new escape sequences or trigraphs.

c

Conformance. More rigorous than a.

s

Code is allowed to be old Sun C. Solaris 2.0 only.

-xpg

Like -p, but produce file gmon.out; use gprof to produce an execution profile. Solaris 2.0 only.

-xsb

Produce symbol-table data for Source Code Browser. Solaris 2.0 only.

-xsbfast

Same as -xsb, but don't actually compile. Solaris 2.0 only.

-xstrconst

Add string literals to text segment, not data segment. Solaris 2.0 only.

-Yc,dir

Specify that item c is searched in directory dir. c can be p, 0, 2, a, b, or l, as explained under -W. c can also be:

I

Include files to search last for (see -I).

P

Libraries; dir is a list of directories, separated by a colon (see -L).

S

Startup object files.

Example

Compile xpop.c and link it to the X libraries:

cc -o xpop xpop.c -lXaw -lXmu -lXt -lX11

Previous: Reference: cb | UNIX in a Nutshell: System V Edition | Next: Reference: cd
Reference: cb | Book Index | Reference: cd


Reference: cflow

Previous: Reference: cdc Chapter 2
UNIX Commands 		Next: Reference: chgrp

cflow

cflow [options] files

Produce an outline (or flowchart) of external function calls for the C, lex, yacc, assembler, or object files. cflow also accepts the cc options -D, -I, and -U.

Options

-dn

Stop outlining when nesting level n is reached.

-i_

Include functions whose names begin with _.

-ix

Include external and static data symbols.

-r

Invert the listing; show the callers of each function and sort in lexographical order by callee.

Previous: Reference: cdc | UNIX in a Nutshell: System V Edition | Next: Reference: chgrp
Reference: cdc | Book Index | Reference: chgrp


Reference: chgrp

Previous: Reference: cflow Chapter 2
UNIX Commands 		Next: Reference: chkey

chgrp

chgrp [options] newgroup files

Change the ownership of one or more files to newgroup. newgroup is either a group ID number or a group name located in /etc/group. You must own the file or be a privileged user to succeed with this command.

Options

-h

Change the group on symbolic links. Normally, chgrp acts on the file referenced by a symbolic link, not on the link itself.

-R

Recursively descend through the directory, including subdirectories and symbolic links, setting the specified group ID as it proceeds.

Previous: Reference: cflow | UNIX in a Nutshell: System V Edition | Next: Reference: chkey
Reference: cflow | Book Index | Reference: chkey


Reference: chkey

Previous: Reference: chgrp Chapter 2
UNIX Commands 		Next: Reference: chmod

chkey

chkey

Prompt for login password and use it to encrypt a new key. See also keylogin and keylogout.

Previous: Reference: chgrp | UNIX in a Nutshell: System V Edition | Next: Reference: chmod
Reference: chgrp | Book Index | Reference: chmod


Reference: chmod

Previous: Reference: chkey Chapter 2
UNIX Commands 		Next: Reference: chown

chmod

chmod [option] mode files

Change the access mode of one or more files. Only the owner of a file or a privileged user may change its mode. Create mode by concatenating the characters from who, opcode, and permission. who is optional (if omitted, default is a); choose only one opcode.

OptionXF

-R

Recursively descend directory arguments while setting modes.

-f

suppress error message upon failure to change a file's mode.

Who

u

User

g

Group

o

Other

a

All (default)

Opcode

+

Add permission

-

Remove permission

=

Assign permission (and remove permission of the unspecified fields)

Permission

r

Read

w

Write

x

Execute

s

Set user (or group) ID

t

Sticky bit; save text (file) mode or prevent removal of files by nonowners (directory)

u

User's present permission

g

Group's present permission

o

Other's present permission

l

Mandatory locking

Alternatively, specify permissions by a 3-digit sequence. The first digit designates owner permission; the second, group permission; and the third, others permission. Permissions are calculated by adding the following octal values:

4

Read

2

Write

1

Execute

Note: A fourth digit may precede this sequence. This digit assigns the following modes:

4

Set user ID on execution

2

Set group ID on execution or set mandatory locking

1

Set sticky bit

Examples

Add execute-by-user permission to file:

chmod u+x file

Either of the following will assign read-write-execute permission by owner (7), read-execute permission by group (5), and execute-only permission by others (1) to file:

chmod 751 file
chmod u=rwx,g=rx,o=x file

Any one of the following will assign read-only permission to file for everyone:

chmod =r file
chmod 444 file
chmod a-wx,a+r file

Set the user ID, assign read-write-execute permission by owner, and assign read-execute permission by group and others:

chmod 4755 file

Previous: Reference: chkey | UNIX in a Nutshell: System V Edition | Next: Reference: chown
Reference: chkey | Book Index | Reference: chown


Reference: chown

Previous: Reference: chmod Chapter 2
UNIX Commands 		Next: Reference: clear

chown

chown [options] newowner files

Change the ownership of one or more files to newowner. (Note: The BSD version lets you change the group as well.) newowner is either a user ID number or a login name located in /etc/passwd.

Options

-h

Change the owner on symbolic links. Normally, chown acts on the file referenced by a symbolic link, not on the link itself.

-R

Recursively descend through the directory, including subdirectories and symbolic links, resetting the ownership ID.

Previous: Reference: chmod | UNIX in a Nutshell: System V Edition | Next: Reference: clear
Reference: chmod | Book Index | Reference: clear


Reference: clear

Previous: Reference: chown Chapter 2
UNIX Commands 		Next: Reference: cmp

clear

clear

Clear the terminal display.

Previous: Reference: chown | UNIX in a Nutshell: System V Edition | Next: Reference: cmp
Reference: chown | Book Index | Reference: cmp


Reference: cmp

Previous: Reference: clear Chapter 2
UNIX Commands 		Next: Reference: cof2elf

cmp

cmp [options] file1 file2

Compare file1 with file2. Use standard input if file1 is -. See also comm and diff. The exit codes are as follows:

0 Files are identical. 1 Files are different. 2 Files are inaccessible.

Options

-l

For each difference, print the byte number in decimal and the differing bytes in octal.

-s

Work silently; print nothing, but return exit codes.

Example

Print a message if two files are the same (exit code is 0):

cmp -s old new && echo 'no changes'

Previous: Reference: clear | UNIX in a Nutshell: System V Edition | Next: Reference: cof2elf
Reference: clear | Book Index | Reference: cof2elf


Reference: cof2elf

Previous: Reference: cmp Chapter 2
UNIX Commands 		Next: Reference: col

cof2elf

cof2elf [options] files

Convert one or more COFF files to ELF format, overwriting the original contents. Input can be object files or archives.

Options

-i

Ignore unrecognized data; do the conversion anyway.

-q

Quiet mode; suppress messages while running.

-Qc

Print information about cof2elf in output (if c = y) or suppress information (if c = n, the default).

-sdir

Save the original files to an existing directory dir.

-V

Print the version of cof2elf on standard error.

Previous: Reference: cmp | UNIX in a Nutshell: System V Edition | Next: Reference: col
Reference: cmp | Book Index | Reference: col


Reference: col

Previous: Reference: cof2elf Chapter 2
UNIX Commands 		Next: Reference: comb

col

col [options]

A postprocessing filter that handles reverse linefeeds and escape characters, allowing output from tbl (or nroff, occasionally) to appear in reasonable form on a terminal.

Options

-b

Ignore backspace characters; helpful when printing man pages.

-f

Process half-line vertical motions, but not reverse line motion. (Normally, half-line input motion is displayed on the next full line.)

-p

Print unknown escape sequences (normally ignored) as regular characters. This option can garble output, so its use is not recommended.

-x

Normally, col saves printing time by converting sequences of spaces to tabs. Use -x to suppress this conversion.

-h

Save printing time by converting sequences of spaces to tabs.

Examples

Run file through tbl and nroff, then capture output on screen by filtering through col and more:

tbl file | nroff | col | more

Save man page output in file.print, stripping out backspaces (which would otherwise appear as ^H):

man file | col -b > file.print

Previous: Reference: cof2elf | UNIX in a Nutshell: System V Edition | Next: Reference: comb
Reference: cof2elf | Book Index | Reference: comb


Reference: comm

Previous: Reference: comb Chapter 2
UNIX Commands 		Next: Reference: compress

comm

comm [options] file1 file2

Compare lines common to the sorted files file1 and file2. Three-column output is produced: lines unique to file1, lines unique to file2, and lines common to both files. comm is similar to diff in that both commands compare two files. But comm can also be used like uniq; that is, comm selects duplicate or unique lines between two sorted files, whereas uniq selects duplicate or unique lines within the same sorted file.

Options

-

Read the standard input.

-1

Suppress printing of column 1.

-2

Suppress printing of column 2.

-3

Suppress printing of column 3.

-12

Print only lines in column 3 (lines common to file1 and file2).

-13

Print only lines in column 2 (lines unique to file2).

-23

Print only lines in column 1 (lines unique to file1).

Example

Compare two lists of top-ten movies, and display items that appear in both lists:

comm -12 siskel_top10 ebert_top10

Previous: Reference: comb | UNIX in a Nutshell: System V Edition | Next: Reference: compress
Reference: comb | Book Index | Reference: compress


Reference: compress

Previous: Reference: comm Chapter 2
UNIX Commands 		Next: Reference: cp

compress

compress [options] [files]

Reduce the size of one or more files using adaptive Lempel-Ziv coding, and move to file.Z. Restore with uncompress or zcat.

Options

-bn

Limit the number of bits in coding to n; n is 9-16, and 16 is the default. A lower n produces a larger, less densely compressed file.

-c

Write to the standard output (do not change files).

-f

Compress unconditionally; i.e., do not prompt before overwriting files.

-v

Print the resulting percentage of reduction for files.

Previous: Reference: comm | UNIX in a Nutshell: System V Edition | Next: Reference: cp
Reference: comm | Book Index | Reference: cp


Reference: cp

Previous: Reference: compress Chapter 2
UNIX Commands 		Next: Reference: cpio

cp

cp [options] file1 file2
cp [options] files directory

Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten). If one of the inputs is a directory, use the -r option.

Options

-i

Prompt for confirmation (y for yes) before overwriting an existing file.

-p

Preserve the modification time and permission modes for the copied file. (Normally cp supplies the permissions of the invoking user.)

-r

Recursively copy a directory, its files, and its subdirectories to a destination directory, duplicating the tree structure. (This option is used with the second command-line format when at least one of the source file arguments is a directory.)

Example

Copy two files to their parent directory (keep the same names):

cp outline memo ..

Previous: Reference: compress | UNIX in a Nutshell: System V Edition | Next: Reference: cpio
Reference: compress | Book Index | Reference: cpio


Reference: cpio

Previous: Reference: cp Chapter 2
UNIX Commands 		Next: Reference: crontab

cpio

cpio flags [options]

Copy file archives in from or out to tape or disk, or to another location on the local machine. Each of the three flags -i, -o, or -p accepts different options.

cpio -i [options] [patterns]

Copy in (extract) files whose names match selected patterns. Each pattern can include filename metacharacters from the Bourne shell. (Patterns should be quoted or escaped so they are interpreted by cpio, not by the shell.) If no pattern is used, all files are copied in. During extraction, existing files are not overwritten by older versions in the archive (unless -u is specified).

cpio -o [options]

Copy out a list of files whose names are given on the standard input.

cpio -p [options] directory

Copy files to another directory on the same system. Destination pathnames are interpreted relative to the named directory.

Comparison of valid options

Options available to the -i, -o, and -p flags are shown respectively in the first, second, and third row below. (The - is omitted for clarity.)

i: 6   b B c C d E f H I k   m M  r R s S t u v V
o: a A   B c C       H     L   M O            v V
p: a           d         l L m      R       u v V

Options

-a

Reset access times of input files.

-A

Append files to an archive (must use with -O).

-b

Swap bytes and half-words. Words are 4 bytes.

-B

Block input or output using 5120 bytes per record (default is 512 bytes per record).

-c

Read or write header information as ASCII characters; useful when source and destination machines are of differing types.

-C n

Like B, but block size can be any positive integer n.

-d

Create directories as needed.

-E file

Extract filenames listed in file from the archives.

-f

Reverse the sense of copying; copy all files except those that match patterns.

-H format

Read or write header information according to format. Values for format are crc (ASCII header containing expanded device numbers), odc (ASCII header containing small device numbers), ustar (IEEE/P1003 Data Interchange Standard header), or tar (tar header).

-I file

Read file as an input archive.

-k

Skip corrupted file headers and I/O errors.

-l

Link files instead of copying.

-L

Follow symbolic links.

-m

Retain previous file modification time.

-M msg

Print msg when switching media. Use variable %d in the message as a numeric ID for the next medium. -M is valid only with -I or -O.

-O file

Direct the output to file.

-r

Rename files interactively.

-R ID

Reassign file ownership and group information to the user's login ID (privileged users only).

-s

Swap bytes.

-S

Swap half-words.

-t

Print a table of contents of the input (create no files). When used with the -v option, resembles output of ls -l.

-u

Unconditional copy; old files can overwrite new ones.

-v

Print a list of filenames.

-V

Print a dot for each file read or written (this shows cpio at work without cluttering the screen).

-6

Process a UNIX 6th Edition archive format file.

Examples

Generate a list of old files using find; use list as input to cpio:

find . -name "*.old" -print | cpio -ocBv\
    > /dev/rst8

Restore from a tape drive all files whose name contains "save" (subdirectories are created if needed):

cpio -icdv "save" < /dev/rst8

To move a directory tree:

find . -depth -print | cpio -padm /mydir

Previous: Reference: cp | UNIX in a Nutshell: System V Edition | Next: Reference: crontab
Reference: cp | Book Index | Reference: crontab


Reference: crontab

Previous: Reference: cpio Chapter 2
UNIX Commands 		Next: Reference: crypt

crontab

crontab [file]
crontab flags [user]

Run crontab on your current crontab file, or specify a crontab file to add to the crontab directory. A privileged user can run crontab for another user by supplying a user after any of the flags. A crontab file is a list of commands, one per line, that will execute automatically at a given time. Numbers are supplied before each command to specify the execution time. The numbers appear in five fields, as follows:

Minute	0-59
Hour	0-23
Day of month	1-31
Month	1-12
Day of week	0-6, with 0 = Sunday

Use a comma between multiple values, a hyphen to indicate a range, and an asterisk to indicate all possible values. For example, assuming the crontab entries below:

59 3 * * 5	find / -print | backup_program
0 0 1,15 * *	echo "Timesheets due" | mail user

The first command backs up the system files every Friday at 3:59 a.m., and the second command mails a reminder on the 1st and 15th of each month.

Flags

-e

Edit the user's current crontab file (or create one).

-l

List the user's file in the crontab directory.

-r

Delete the user's file in the crontab directory.

Previous: Reference: cpio | UNIX in a Nutshell: System V Edition | Next: Reference: crypt
Reference: cpio | Book Index | Reference: crypt


Reference: crypt

Previous: Reference: crontab Chapter 2
UNIX Commands 		Next: Reference: cscope

crypt

crypt [password] < file > encryptedfile

Encrypt a file to prevent unauthorized access. password is either a string of characters you choose or the flag -k, which assigns the value of environment variable CRYPTKEY as the password. The same password is used to encrypt a file or to decrypt an encrypted file. If no password is given, crypt prompts for one. crypt is available only in the United States (due to export restrictions).

Previous: Reference: crontab | UNIX in a Nutshell: System V Edition | Next: Reference: cscope
Reference: crontab | Book Index | Reference: cscope


Reference: cscope

Previous: Reference: crypt Chapter 2
UNIX Commands 		Next: Reference: csh

cscope

cscope [options] files

Interactive utility for finding code fragments in one or more C, lex, or yacc source files. cscope builds a symbol cross-reference (named cscope.out by default) and then calls up a menu. The menu prompts the user to search for functions, macros, variables, preprocessor directives, etc. Type ? to list interactive commands. Subsequent calls to cscope rebuild the cross-reference if needed (i.e., if filenames or file contents have changed). Source filenames can be stored in a file cscope.files. This file can then be specified instead of files. Options -I, -p, and -T are also recognized when placed in cscope.files.

Options

-b

Build the symbol cross-reference only.

-C

Ignore uppercase/lowercase differences in searches.

-c

Create output in ASCII (don't compress data).

-d

Don't update the cross-reference.

-e

Don't show the CTRL-E prompt between files.

-f out

Name the cross-reference file out instead of cscope.out.

-I dir

Search for include files in dir before searching the default (/usr/include). cscope searches the current directory, then dir, then the default.

-i in

Check source files whose names are listed in in rather than in cscope.files.

-L

Use with -n pat to do a single search.

-l

Run in line mode; useful from within a screen editor.

-P path

Use with -d to prepend path to filenames in existing cross-reference. This lets you run cscope without changing to directory where cross-reference was built.

-p n

Show the last n parts of the filename path. Default is 1 (filename); use 0 to suppress the filename.

-s dir

Look for source files in directory dir instead of in current directory.

-T

Match only the first eight characters of C symbols.

-U

Ignore file timestamps (assume no files changed).

-u

Build cross-reference unconditionally (assume all files changed).

-V

Print the cscope version on first line of screen.

-n pat

Go to field n of input (starting at 0), then find pat.

Previous: Reference: crypt | UNIX in a Nutshell: System V Edition | Next: Reference: csh
Reference: crypt | Book Index | Reference: csh


Reference: csplit

Previous: Reference: csh Chapter 2
UNIX Commands 		Next: Reference: ctags

csplit

csplit [options] file arguments

Separate file into sections and place sections in files named xx00 through xx n (n < 100), breaking file at each pattern specified in arguments. See also split.

Options

-f file

Name new files file 00 through filen (default is xx00 through xx n).

-k

Keep newly created files, even when an error occurs (which would normally remove these files). This is useful when you need to specify an arbitrarily large repeat argument, {n}, and you don't want the "out of range" error to remove the new files.

-s

Suppress all character counts.

Arguments

Any one or a combination of the following expressions. Arguments containing blanks or other special characters should be surrounded by single quotes.

/expr/

Create file from the current line up to the line containing the regular expression expr. This argument takes an optional suffix of the form +n or -n, where n is the number of lines below or above expr.

%expr%

Same as /expr/ except no file is created for lines previous to line containing expr.

num

Create file from current line up to line number num.

{n}

Repeat argument n times. May follow any of the above arguments. Files will split at instances of expr or in blocks of num lines.

Examples

Create up to 20 chapter files from the file novel:

csplit -k -f chap. novel '%CHAPTER%' '{20}'

Create up to 100 address files (xx00 through xx99), each four lines long, from a database named address_list:

csplit -k address_list 4 {99}

Previous: Reference: csh | UNIX in a Nutshell: System V Edition | Next: Reference: ctags
Reference: csh | Book Index | Reference: ctags


Reference: ctags

Previous: Reference: csplit Chapter 2
UNIX Commands 		Next: Reference: ctrace

ctags

ctags [options] files

Create a list of function and macro names that are defined in the specified C, Pascal, FORTRAN, yacc, or lex source files. The output list (named tags by default) contains lines of the form: name file context where name is the function or macro name, file is the source file in which name is defined, and context is a search pattern that shows the line of code containing name. After the list of tags is created, you can invoke vi on any file and type:

:set tags=tagsfile
:tag name

This switches the vi editor to the source file associated with the name listed in tagsfile (which you specify with -f).

Options

-a

Append tag output to existing list of tags.

-B

context uses backward search patterns.

-F

context uses forward search patterns (default).

-ftagsfile

Place output in tagsfile (default is tags).

-t

Include typedefs as tags.

-u

Update tags file to reflect new locations of functions (e.g., when functions are moved to a different source file). Old tags are deleted; new tags are appended.

-v

Produce a listing (index) of each function, source file, and page number (1 page = 64 lines). -v is intended to create a file for use with vgrind, which is available in the BSD compatibility package.

-w

Suppress warning messages.

-x

Produce a listing of each function, its line number, source file, and context.

Examples

Store tags in Taglist for all C programs:

ctags -f Taglist *.c

Update tags and store in Newlist:

ctags -u -f Newlist *.c

Previous: Reference: csplit | UNIX in a Nutshell: System V Edition | Next: Reference: ctrace
Reference: csplit | Book Index | Reference: ctrace


Reference: ctrace

Previous: Reference: ctags Chapter 2
UNIX Commands 		Next: Reference: cu

ctrace

ctrace [options] [file]

Debug a C program. ctrace reads the C source file and writes a modified version to standard output. Common options are -f and -v. ctrace also accepts the cc options -D, -I, and -U.

Options

-b

Trace only the basic C functions (SVR3 only).

-e

Print variables as floating point.

-f functions

Trace only the specified functions.

-l n

Follow a statement loop n times (default is 20).

-o

Print variables in octal.

-p 's'

Print trace output via function s (default is printf ).

-P

Run the C preprocessor before tracing.

-Qc

Print information about ctrace in output (if c = y) or suppress information (if c = n, the default).

-rfile

Change the trace function package to file (default is runtime.c).

-s

Suppress certain redundant code.

-tn

Trace n variables per statement (default is 10; maximum is 20).

-u

Print variables as unsigned.

-v functions

Do not trace the specified functions.

-V

Print version information on standard error.

-x

Print variables as floating point.

Previous: Reference: ctags | UNIX in a Nutshell: System V Edition | Next: Reference: cu
Reference: ctags | Book Index | Reference: cu


Reference: cu

Previous: Reference: ctrace Chapter 2
UNIX Commands 		Next: Reference: cut

cu

cu [options] [destination]

Call up another UNIX system or a terminal via a direct line or a modem. A non-UNIX system can also be called.

Options

-bn

Process lines using n-bit characters (7 or 8).

-cname

Search UUCP's Devices file and select the local area network that matches name (this assumes connection to a system).

-d

Print diagnostics.

-e

Send even-parity data to remote system.

-h

Emulate local echo and support calls to other systems expecting terminals to use half duplex mode.

-lline

Communicate on line device (e.g., /dev/tty001).

-n

Prompt user for a telephone number.

-o

Use odd parity (opposite of -e).

-sn

Set transmission rate to n (e.g., 1200, 2400, 9600 bps). Default is Any.

-t

Dial an ASCII terminal that has auto answer set.

Destination

telno

The telephone number of the modem to connect to.

system

Call the system known to uucp (run uuname to list valid system names).

addr

An address specific to your local area network.

cu runs as two processes: transmit and receive. Transmit reads from standard input and passes lines to the remote system; receive reads data from the remote system and passes lines to standard output. Lines that begin with a tilde (~) are treated as commands and are not passed.

Transmit options

~.

Terminate the conversation.

~!

Escape to an interactive shell on the local system.

~!cmd...

Run command on local system (via sh -c).

~$cmd...

Run command locally; send output to remote system.

~%cd

Change directory on the local system.

~%take file [target]

Copy file from remote system to target on the local system. If target is omitted, file is used in both places.

~%put file [target]

Copy file from the local system to target on the remote system. If target is omitted, file is used in both places.

~ ~ ...

Use two tildes when you want to pass a line that begins with a tilde. This lets you issue commands to more than one system in a cu chain. For example, use ~~. to terminate the conversation on a second system cu'd to from the first.

~%b

Send a BREAK sequence to remote system.

~%d

Turn debug mode on or off.

~t

Print termio structure for local terminal.

~l

Print termio structure for communication line.

~%ifc

Turn on/off the DC3/DC1 XON/XOFF control protocol (characters ^S, ^Q) for the remainder of the session (formerly ~%nostop, which is still valid).

~%ofc

Set output flow control either on or off.

~%divert

Allow/prevent diversions not specified by ~%take.

~%old

Allow/prevent old-style syntax for diversions received.

Examples

Connect to terminal line /dev/ttya at 1200 baud:

cu -s1200 -l/dev/ttya

Connect to modem with phone number 555-9876:

cu 5559876

Connect to system named usenix:

cu usenix

Previous: Reference: ctrace | UNIX in a Nutshell: System V Edition | Next: Reference: cut
Reference: ctrace | Book Index | Reference: cut


Reference: cut

Previous: Reference: cu Chapter 2
UNIX Commands 		Next: Reference: cxref

cut

cut options [files]

Select a list of columns or fields from one or more files. Option -c or -f must be specified. list is a sequence of integers. Use a comma between separate values and a hyphen to specify a range (e.g., 1-10,15,20 or 50-). See also paste, join, and newform.

Options

-clist

Cut the column positions identified in list.

-dc

Use with -f to specify field delimiter as character c (default is tab); special characters (e.g., a space) must be quoted.

-flist

Cut the fields identified in list.

-s

Use with -f to suppress lines without delimiters.

Examples

Extract usernames and real names from /etc/passwd:

cut -d: -f1,5 /etc/passwd

Find out who is logged on, but list only login names:

who | cut -d" " -f1

Cut characters in the fourth column of file, and paste them back as the first column in the same file:

cut -c4 file | paste - file

Previous: Reference: cu | UNIX in a Nutshell: System V Edition | Next: Reference: cxref
Reference: cu | Book Index | Reference: cxref


Reference: cxref

Previous: Reference: cut Chapter 2
UNIX Commands 		Next: Reference: date

cxref

cxref [options] files

Build a cross-reference table for each of the C source files. The table lists all symbols, providing columns for the name and the associated function, file, and line. In the table, symbols are marked by = if assigned, - if declared, or * if defined. cxref also accepts the cc options -D, -I, and -U.

Options

-c

Report on all files in a single table.

-C

Don't execute the second pass of cxref; save output from first pass in .cx files. (Like -c in lint and cc.)

-d

Simplify report by omitting print declarations.

-F

Print files using full pathname, not just the filename.

-l

Don't print local variables.

-L[n]

Limit the "LINE" field to n columns (default is 5).

-o file

Send output to file.

-s

Silent mode; don't print input filenames.

-t

Format for 80-column listing.

-V

Print version information on standard error.

-w[n]

Format for maximum width of n columns (default is 80; n must be more than 50).

-Wn1,n2,n3,n4

Set the width of each (or any) column to n1, n2, n3, or n4 (respective defaults are 15, 13, 15, and 20). Column headings are NAME, FILE, FUNCTION, and LINE, respectively.

Previous: Reference: cut | UNIX in a Nutshell: System V Edition | Next: Reference: date
Reference: cut | Book Index | Reference: date


Reference: dc

Previous: Reference: dbx Chapter 2
UNIX Commands 		Next: Reference: dd

dc

dc [file]

An interactive desk calculator program that performs arbitrary- precision integer arithmetic (input may be taken from a file). Normally you don't run dc directly, since it's invoked by bc (see bc). dc provides a variety of one-character commands and operators that perform arithmetic; dc works like a Reverse Polish calculator; therefore, operators and commands follow the numbers they affect. Operators include + - / * % ^ (as in C); some simple commands include:

p

Print current result.

q

Quit dc.

c

Clear all values on the stack.

v

Take square root.

i

Change input base; similar to bc's ibase.

o

Change output base; similar to bc's obase.

k

Set scale factor (number of digits after decimal); similar to bc's scale.

!

Remainder of line is a UNIX command.

Examples

3 2 ^ p	Evaluate 3 squared, then print result.
9
8 * p	Current value (9) times 8, then print result.
72
47 - p	Subtract 47 from 72, then print result.
25
v p	Square root of 25, then print result.
5
2 o p	Display current result in base 2.
101

Note: Spaces are not needed except between numbers.

Previous: Reference: dbx | UNIX in a Nutshell: System V Edition | Next: Reference: dd
Reference: dbx | Book Index | Reference: dd


Reference: dd

Previous: Reference: dc Chapter 2
UNIX Commands 		Next: Reference: delta

dd

dd [option=value]

Make a copy of an input file (if=) using the specified conditions, and send the results to the output file (or standard output if of is not specified). Any number of options can be supplied, although if and of are the most common and are usually specified first. Because dd can handle arbitrary block sizes, it is useful when converting between raw physical devices.

Options

bs=n

Set input and output block size to n bytes; this option supersedes ibs and obs.

cbs=n

Set the size of the conversion buffer (logical record length) to n bytes. Use only if the conversion flag is ascii, ebcdic, ibm, block, or unblock.

conv=flags

Convert the input according to one or more (comma-separated) flags listed below. The first five flags are mutually exclusive.

ascii

EBCDIC to ASCII.

ebcdic

ASCII to EBCDIC.

ibm

ASCII to EBCDIC with IBM conventions.

block

Variable-length records (i.e., those terminated by a newline) to fixed-length records.

unblock

Fixed-length records to variable-length.

lcase

Uppercase to lowercase.

ucase

Lowercase to uppercase.

noerror

Continue processing when errors occur (up to 5 in a row).

swab

Swap all pairs of bytes.

sync

Pad input blocks to ibs.

count=n

Copy only n input blocks.

files=n

Copy n input files (e.g., from magnetic tape), then quit.

ibs=n

Set input block size to n bytes (default is 512).

if=file

Read input from file (default is standard input).

obs=n

Set output block size to n bytes (default is 512).

of=file

Write output to file (default is standard output).

iseek=n

Seek n blocks from start of input file (like skip but more efficient for disk file input).

oseek=n

Seek n blocks from start of output file.

seek=n

Same as oseek (retained for compatibility).

skip=n

Skip n input blocks; useful with magnetic tape.

You can multiply size values (n) by a factor of 1024, 512, or 2 by appending the letter k, b, or w, respectively. You can use the letter x as a multiplication operator between two numbers.

Examples

Convert an input file to all lowercase:

dd if=caps_file of=small_file conv=lcase

Retrieve variable-length data; write it as fixed-length to out:

data_retrieval_cmd | dd of=out conv=sync,block

Previous: Reference: dc | UNIX in a Nutshell: System V Edition | Next: Reference: delta
Reference: dc | Book Index | Reference: delta


Reference: diff3

Previous: Reference: diff Chapter 2
UNIX Commands 		Next: Reference: diffmk

diff3

diff3 [options] file1 file2 file3

Compare three files and report the differences with the following codes:

====

All three files differ.

====1

file1 is different.

====2

file2 is different.

====3

file3 is different.

Options

-e

Create an ed script to incorporate into file1 all differences between file2 and file3.

-E

Same as -e, but mark with angle brackets any lines that differ between all three files.

-x

Create an ed script to incorporate into file1 all differences between all three files.

-X

Same as -x, but mark with angle brackets any lines that differ between all three files.

-3

Create an ed script to incorporate into file1 differences between file1 and file3.

Previous: Reference: diff | UNIX in a Nutshell: System V Edition | Next: Reference: diffmk
Reference: diff | Book Index | Reference: diffmk


Reference: diffmk

Previous: Reference: diff3 Chapter 2
UNIX Commands 		Next: Reference: dircmp

diffmk

/usr/ucb/diffmk oldfile newfile markedfile

A useful program for reviewing changes between drafts of a document. diffmk compares two versions of a file (oldfile and newfile) and creates a third file (markedfile) that contains troff "change mark" requests. When markedfile is formatted with nroff or troff, the differences between the two files will be marked in the margin (via the .mc request). diffmk uses a | to mark changed lines and a * to mark deleted lines. Note that change marks are produced even if the changes are inconsequential (e.g., extra blanks, different input line lengths).

Example

To run diffmk on multiple files, it's convenient to set up directories in which to keep the old and new versions of your files, and to create a directory in which to store the marked files:

$ mkdir OLD NEW CHANGED

Move your old files to OLD and your new files to NEW. Then use this rudimentary Bourne shell script:

$ cat do.mark
for file
do
echo "Running diffmk on $file ..."
diffmk ../OLD/$file $file ../CHANGED/$file
done

You must run the script in the directory of new files:

$ cd NEW
$ do.mark Ch*

Previous: Reference: diff3 | UNIX in a Nutshell: System V Edition | Next: Reference: dircmp
Reference: diff3 | Book Index | Reference: dircmp


Reference: dircmp

Previous: Reference: diffmk Chapter 2
UNIX Commands 		Next: Reference: dirname

dircmp

dircmp [options] dir1 dir2

Compare the contents of dir1 and dir2. See also diff and cmp.

Options

-d

Execute diff on the files which differ.

-s

Don't report files that are identical.

-wn

Change the output line length to n (default is 72).

Previous: Reference: diffmk | UNIX in a Nutshell: System V Edition | Next: Reference: dirname
Reference: diffmk | Book Index | Reference: dirname


Reference: file

Previous: Reference: fgrep Chapter 2
UNIX Commands 		Next: Reference: find

file

file [options] files

Classify the named files according to the type of data they contain. file checks the magic file (usually /etc/magic) to identify some file types.

Options

-c

Check the format of the magic file (files argument is invalid with -c ).

-flist

Run file on the filenames in list.

-h

Do not follow symbolic links.

-L

Test the file that is referenced by a symbolic link, rather than the link itself.

-mfile

Use file as the magic file instead of /etc/magic.

Many file types are understood. Output lists each filename, followed by a brief classification such as:

ascii text
c program text
c-shell commands
data
empty
iAPX 386 executable
directory
[nt]roff, tbl, or eqn input text
shell commands
symbolic link to ../usr/etc/arp

Example

List all files that are deemed to be troff/nroff input:

file * | grep roff

Previous: Reference: fgrep | UNIX in a Nutshell: System V Edition | Next: Reference: find
Reference: fgrep | Book Index | Reference: find


Reference: gcore

Previous: Reference: ftp Chapter 2
UNIX Commands 		Next: Reference: gencat

gcore

gcore [option] process_ids

Create ("get") a core image of each running process specified. The core image can be used with debugging utilities such as sdb. adb or dbx.

Option

-o file

Create core file named file.process_id (default is core.process_id).

Previous: Reference: ftp | UNIX in a Nutshell: System V Edition | Next: Reference: gencat
Reference: ftp | Book Index | Reference: gencat


Reference: gprof

Previous: Reference: gettxt Chapter 2
UNIX Commands 		Next: Reference: grep

gprof

gprof [options] [objfile [pfile]]

Solaris 2.0 only. Display call-graph profile data of C programs. Programs compiled with the -pg option of cc (and other compilers) produce a call-graph profile file pfile, whose default name is gmon.out. The specified object file objfile (a.out by default) contains a symbol table that is read and correlated with pfile. See also prof and lprof

Options

-a

Don't print statically declared functions.

-b

Brief; don't print field descriptions in the profile.

-c

Find the program's static call-graph. Call counts of 0 indicate static-only parents or children.

-e name

Don't print the graph profile entry for the routine name. -e may be repeated.

-E name

Like -e above. In addition, during time computations, omit the time spent in name.

-f name

Print the graph profile entry only for routine name. -f may be repeated.

-F name

Like -f above. In addition, during time computations, use only the times of the printed routines. -F may be repeated, and it overrides -E.

-s

With this option you supply one or more existing pfiles. Sum the information in all specified profile files and send it to a profile file called gmon.sum. Useful for accumulating data across several runs.

-z

Show routines that have zero usage. Useful with -c to find out which routines were never called.

Previous: Reference: gettxt | UNIX in a Nutshell: System V Edition | Next: Reference: grep
Reference: gettxt | Book Index | Reference: grep


Reference: iconv

Previous: Reference: hostname Chapter 2
UNIX Commands 		Next: Reference: id

iconv

iconv -f from_encoding -t to_encoding [file]

Convert the contents of file from one character set (from_encoding) to another (to_encoding). If the destination character set provides no equivalent for a character, it is converted to an underscore (_). Supported conversion sets are listed in the directory /usr/lib/iconv.

Previous: Reference: hostname | UNIX in a Nutshell: System V Edition | Next: Reference: id
Reference: hostname | Book Index | Reference: id


Reference: lint

Previous: Reference: line Chapter 2
UNIX Commands 		Next: Reference: ln

lint

lint [options] files

Detect bugs, portability problems, and other possible errors in the specified C programs. By default, lint uses definitions in the C library llib-lc.ln. If desired, output from .c files can be saved in "object files" having a .ln suffix. A second lint pass can be invoked on .ln files and libraries for further checking. lint also accepts the cc options -D, -I, -U, and -X. See also the Nutshell Handbook, Checking C Programs with lint. Note: This command checks programs written in ANSI C; use /usr/ucb/lint if you want to check programs written in Kernighan and Ritchie's C. Note also that options -a, -b, -h, and -x have exactly the opposite meaning in the versions for BSD and System V.

Options

-a

Ignore long values assigned to variables that aren't long.

-b

Ignore break statements that cannot be reached.

-c

Don't execute the second pass of lint; save output from first pass in .ln files. (Same as BSD -i option.)

-Cname

Create a lint library named llib-l name.ln.

-F

Print files using full pathname, not just the filename.

-h

Don't test for bugs, bad style, or extraneous information.

-k

Re-enable warnings that are normally suppressed by directive /* LINTED [message] */, and print the additional message (if specified).

-Ldir

Search for lint libraries in directory dir before searching standard directories.

-lx

Use library llib-l x.ln in addition to llib-lc.ln.

-m

Ignore extern declarations that could be static.

-n

Do not check for compatibility.

-o lib

Create a lint library named llib-l.lib.ln from the output of the first pass of lint.

-p

Check for portability to variants of C.

-Rfile

Place .ln output (from a .c file) in file, for use by cxref.

-s

Produce short (one-line) diagnostics. Solaris 2.0 only.

-u

Ignore functions or external variables that are undefined or unused.

-v

Ignore unused arguments within functions; same as specifying the directive /* ARGSUSED */.

-V

Print product name and release on standard error.

-Wfile

Same as -R, except file is prepared for cflow.

-x

Ignore unused variables referred to by extern declarations.

-y

Same as using the directive /* LINTLIBRARY */, which is the same as supplying options -v and -x.

Previous: Reference: line | UNIX in a Nutshell: System V Edition | Next: Reference: ln
Reference: line | Book Index | Reference: ln


Reference: login

Previous: Reference: ln Chapter 2
UNIX Commands 		Next: Reference: logname

login

login [options]

Sign on and identify yourself to the system. At the beginning of each terminal session, the system prompts you for your username and, if relevant, a password. The options are usually not used.

Options

user

Sign on as user (instead of being prompted).

-dtty

Specify the pathname of the tty that serves as the login port.

var=value

When specified after the username, assign a value to one or more environment variables. PATH and SHELL can't be changed.)

Previous: Reference: ln | UNIX in a Nutshell: System V Edition | Next: Reference: logname
Reference: ln | Book Index | Reference: logname


Reference: logname

Previous: Reference: login Chapter 2
UNIX Commands 		Next: Reference: lorder

logname

logname

Display your login name. (Print the value of the LOGNAME environment variable located in /etc/profile.)

Previous: Reference: login | UNIX in a Nutshell: System V Edition | Next: Reference: lorder
Reference: login | Book Index | Reference: lorder


Reference: lorder

Previous: Reference: logname Chapter 2
UNIX Commands 		Next: Reference: lp

lorder

lorder objfiles

Take object filenames (e.g., files with .o suffix) and output a list of related pairs. The first file listed includes references to external identifiers that are defined in the second. lorder output can be sent to tsort to make link editing of an archive more efficient.

Example

To produce an ordered list of object files, and replace them in the library program_arch (provided they are newer):

ar cru program_arch `lorder *.o | tsort`

Previous: Reference: logname | UNIX in a Nutshell: System V Edition | Next: Reference: lp
Reference: logname | Book Index | Reference: lp


Reference: lp

Previous: Reference: lorder Chapter 2
UNIX Commands 		Next: Reference: lpq

lp

lp [options] [files]

Send files to the printer. To send standard input, specify - as one of the files.

Options

-c

Copy files to print spooler; if changes are made to file while it is still queued for printing, the printout is unaffected.

-d dest

Send output to destination printer named dest.

-d any

Used after -f or -S to print the request on any printer that supports the given name.

-f name

Print request on preprinted form name. name references printer attributes set by the administrative command lpforms.

-H action

Print according to the named action: hold (notify before printing), resume (resume a held request), immediate (print next; privileged users only).

-i IDs

Override lp options used for request IDs currently in the queue; specify new lp options after -i. For example, change the number of copies sent.

-m

Send mail after files are printed.

-n number

Specify the number of copies to print.

-o options

Set one or more printer-specific options. Standard options include:

nobanner

Omit banner page (separator) from request.

nofilebreak

Suppress formfeeds between files.

cpi=n

Print n characters per inch. n can also be pica, elite, or compressed.

lpi=n

Print n lines per inch.

length=n

Print pages n units long; e.g., 11i (inches), 66 (lines).

width=n

Print pages n units wide; e.g., 8.5i (inches) 72 (columns).

stty=list

Specify a quoted list of stty options.

-P list

Print only the page numbers specified in list.

-q n

Print request with priority level n (39 = lowest).

-r

Don't adapt request if content isn't suitable; reject instead. (Obscure; used only with -T.)

-s

Suppress messages.

-S name

Use the named print wheel or character set for printing.

-t title

Use title on the printout's banner page.

-T content

Send request to a printer that supports content (default is simple; an administrator sets content via lpadmin -I).

-w

Write a terminal message after files are printed (same as -m if user isn't logged on). Confirm the printing with a message on the user's terminal.

-y mode

Print according to locally-defined modes.

Examples

Send mail after printing five copies of report:

lp -n 5 -m report

Format and print thesis; print title too:

nroff -ms thesis | lp - title

Previous: Reference: lorder | UNIX in a Nutshell: System V Edition | Next: Reference: lpq
Reference: lorder | Book Index | Reference: lpq


Reference: lpq

Previous: Reference: lp Chapter 2
UNIX Commands 		Next: Reference: lpr

lpq

/usr/ucb/lpq [options] [job#s] [users]

Show the printer queue. Standard SVR4 uses lpstat.

Previous: Reference: lp | UNIX in a Nutshell: System V Edition | Next: Reference: lpr
Reference: lp | Book Index | Reference: lpr


Reference: lprof

Previous: Reference: lprm Chapter 2
UNIX Commands 		Next: Reference: lpstat

lprof

lprof [options]
lprof -m files [-T] -d out

Display a program's profile data on a line-by-line basis. Data includes a list of source files, each source code line (with line numbers), and the number of times each line was executed. By default, lprof interprets the profile file prog.cnt. This file is generated by specifying cc -ql when compiling a program or when creating a shared object named prog (default is a.out). The PROFOPTS environment variable can be used to control profiling at run time. See also prof and gprof.

Options

-c file

Read input profile file instead of prog.cnt.

-d out

Store merged profile data in file out. Must be used with -m.

-I dir

Search for include files in dir as well as in the default place (/usr/include).

-m files

Merge several profile files and total the execution counts. files are of the form f1.cnt, f2.cnt, f3.cnt , etc., where each file contains the profile data from a different run of the same program. Used with -d.

-o prog

Look in the profile file for a program named prog instead of the name used when the profile file was created. -o is needed when files have been renamed or moved.

-p

Print the default listing; useful with -r and -s.

-r list

Used with -p to print only the source files given in list.

-s

For each function, print the percentage of code lines that are executed.

-T

Ignore timestamp of executable files being profiled. Normally, times are checked to insure that the various profiles were made from the same version of an executable.

-V

Print the version of lprof on standard error.

-x

Omit execution counts. For lines that executed, show only the line numbers; for lines that didn't execute, print the line number, the symbol [U], and the source line.

Previous: Reference: lprm | UNIX in a Nutshell: System V Edition | Next: Reference: lpstat
Reference: lprm | Book Index | Reference: lpstat


Reference: lpstat

Previous: Reference: lprof Chapter 2
UNIX Commands 		Next: Reference: lptest

lpstat

lpstat [options]

Print the lp print queue status. With options that take a list argument, omitting the list produces all information for that option. list can be separated by commas or, if enclosed in double quotes, by spaces.

Options

-a [list]

Show whether the list of printer or class names is accepting requests.

-c [list]

Show information about printer classes named in list.

-d

Show the default printer destination.

-D

Use after -p to show a brief printer description.

-f [list]

Verify that the list of forms is known to lp.

-l

Use after -f to describe available forms, after -p to show printer configurations, or after -S to describe printers appropriate for the specified character set or print wheel.

-o [list]

Show the status of output requests. list contains printer names, class names, or request IDs.

-p [list]

Show the status of printers named in list.

-r

Show whether the print scheduler is on or off.

-R

Show the job's position in the print queue.

-s

Summarize the print status (shows almost everything).

-S [list]

Verify that the list of character sets or print wheels is known to lp.

-t

Show all status information (reports everything).

-u [list]

Show request status for users on list. list can be:

user

user on local machine.

all

All users on local machine.

host!user

user on machine host.

host!all

All users on host.

all! user

user not on local machine.

all!all

All users not on local machine.

-v [list]

Show device associated with each printer named in list.

Previous: Reference: lprof | UNIX in a Nutshell: System V Edition | Next: Reference: lptest
Reference: lprof | Book Index | Reference: lptest


Reference: lptest

Previous: Reference: lpstat Chapter 2
UNIX Commands 		Next: Reference: ls

lptest

/usr/ucb/lptest [length [n]]

Display all 96 printable ASCII characters on the standard output. Characters are printed in each position, forming a "ripple pattern." You can specify the output line length (default is 79) and display n lines of output (default is 200). lptest is useful for testing printers and terminals or for running shell scripts with dummy input.

Previous: Reference: lpstat | UNIX in a Nutshell: System V Edition | Next: Reference: ls
Reference: lpstat | Book Index | Reference: ls


Reference: ls

Previous: Reference: lptest Chapter 2
UNIX Commands 		Next: Reference: m4

ls

ls [options] [names]

If no names are given, list the files in the current directory. With one or more names, list files contained in a directory name or that match a file name. names can include filename metacharacters. The options let you display a variety of information in different formats. The most useful options include -F, -R, -l, and -s. Some options don't make sense together; e.g., -u and -c.

Options

-a

List all files, including the normally hidden . files.

-b

Show nonprinting characters in octal.

-c

List files by creation/modification time.

-C

List files in columns (the default format).

-d

List only the directory name, not its contents.

-f

Interpret each name as a directory (files are ignored).

-F

Flag filenames by appending / to directories, * to executable files, and @ to symbolic links. @ to symbolic links, and = to sockets.

-g

Like -l, but omit owner name (show group). Add group name to -l listing.

-i

List the inode for each file.

-l

Long format listing (includes permissions, owner, size, modification time, etc.).

-L

List the file or directory referenced by a symbolic link rather than the link itself.

-m

Merge the list into a comma-separated series of names.

-n

Like -l, but use GID and UID numbers instead of owner and group names.

-o

Like -l, but omit group name (show owner).

-p

Mark directories by appending / to them.

-q

Show nonprinting characters as ?.

-r

List files in reverse order (by name or by time).

-R

Recursively list subdirectories as well as current directory.

-s

Print size of the files in blocks. in kilobytes.

-t

List files according to modification time (newest first).

-u

List files according to the file access time.

-x

List files in rows going across the screen.

-1

Print one entry per line of output.

Examples

List all files in the current directory and their sizes; use multiple columns and mark special files:

ls -asCF

List the status of directories /bin and /etc:

ls -ld /bin /etc

List C source files in the current directory, the oldest first:

ls -rt *.c

Count the files in the current directory:

ls | wc -l

Previous: Reference: lptest | UNIX in a Nutshell: System V Edition | Next: Reference: m4
Reference: lptest | Book Index | Reference: m4


Reference: m4

Previous: Reference: ls Chapter 2
UNIX Commands 		Next: Reference: m4

m4

m4 [options] [files]

Previous: Reference: ls | UNIX in a Nutshell: System V Edition | Next: Reference: m4
Reference: ls | Book Index | Reference: m4


Reference: m4

Previous: Reference: m4 Chapter 2
UNIX Commands 		Next: Reference: mail

m4

m4 [files]

Macro processor for RATFOR, C, and other program files.

Options

-Bn

Set push-back and argument collection buffers to n (default is 4,096).

-Dname[=value]

Define name as value or, if value is not specified, define name as null.

-e

Operate interactively, ignoring interrupts.

-Hn

Set symbol table hash array to n (default is 199).

-s

Enable line-sync output for the C preprocessor.

-Sn

Set call stack size to n (default is 100 slots).

-Tn

Set token buffer size to n (default is 512 bytes).

-Uname

Undefine name.

Previous: Reference: m4 | UNIX in a Nutshell: System V Edition | Next: Reference: mail
Reference: m4 | Book Index | Reference: mail


Reference: mail

Previous: Reference: m4 Chapter 2
UNIX Commands 		Next: Reference: mailalias

mail

mail [options] [users]

Read mail (if no users listed), or send mail to other users. Type ? for a summary of commands. Esoteric debugging options exist (not listed) for system administrators.

Options for sending mail

-m type

Print a "Message-type:" line at the heading of the letter, followed by type of message.

-t

Print a "To:" line at the heading of the letter, showing the names of the recipients.

-w

Force mail to be sent to remote users without waiting for remote transfer program to be completed.

-F

Store message in a file named after the first recipient.

-h n

Stop trying to send after making n network connections, or "hops" (useful for avoiding infinite loops).

-i

Ignore interrupts (useful on modems).

-n

-r address

Specify a return address for mail you send.

-s subject

Print subject in the subject header field.

-U

Convert uucp-type addresses to Internet format.

-v

Verbose; display status of mail delivery.

Options for reading mail

Options -i, -n, -U, and -v, are also available.

-e

Test for the existence of mail without printing it. Exit status is 0 if mail exists; otherwise 1.

-f file

Read mail from alternate mailbox file.

-F names

Forward all incoming mail to recipient names.

-h

Display a window of messages rather than the latest message.

-p

Print all messages without pausing.

-P

Print messages with all header lines displayed.

-q

Terminate on an interrupt.

-r

Print oldest messages first.

Previous: Reference: m4 | UNIX in a Nutshell: System V Edition | Next: Reference: mailalias
Reference: m4 | Book Index | Reference: mailalias


Reference: mailalias

Previous: Reference: mail Chapter 2
UNIX Commands 		Next: Reference: mailx

mailalias

mailalias [options] names

Display the e-mail addresses associated with one or more alias names. mailalias displays addresses that are listed in the files /var/mail/name, $HOME/lib/names, and in the files pointed to by the list in /etc/mail/namefiles. mailalias is called by mail.

Options

-s

Suppress name; show only corresponding mail address.

-v

Verbose mode; show debugging information.

Previous: Reference: mail | UNIX in a Nutshell: System V Edition | Next: Reference: mailx
Reference: mail | Book Index | Reference: mailx


Reference: mailx

Previous: Reference: mailalias Chapter 2
UNIX Commands 		Next: Reference: make

mailx

mailx [options] [users]

Read mail, or send mail to other users. For a summary of commands, type ? in command mode (e.g., when reading mail) or ~? in input mode (e.g., when sending mail). The start-up file .mailrc in the user's home directory is useful for setting display variables and for defining alias lists.

Options

-d

Set debugging.

-e

Test for the existence of mail without printing it. Exit status is 0 if mail exists; otherwise 1.

-f [file]

Read mail in alternate file (default is mbox).

-F

Store message in a file named after the first recipient.

-h n

Stop trying to send after making n network connections, or "hops" (useful for avoiding infinite loops).

-H

Print mail headers only.

-i

Ignore interrupts (useful on modems); same as ignore environment variable.

-I

Use with -f when displaying saved news articles; newsgroup and article-ID headers are included.

-n

Do not read the startup mailx.rc file.

-N

Don't print mail headers.

-r address

Specify a return address for mail you send.

-s sub

Print string sub in the subject header field.

-T file

Record message IDs and article IDs (of news articles) in file.

-u user

Read user's mail.

-U

Convert uucp-type addresses to Internet format.

-V

Print version number of mailx and exit.

Previous: Reference: mailalias | UNIX in a Nutshell: System V Edition | Next: Reference: make
Reference: mailalias | Book Index | Reference: make


Reference: make

Previous: Reference: mailx Chapter 2
UNIX Commands 		Next: Reference: makekey

make

make [options] [targets]

Update one or more targets according to dependency instructions in a description file in the current directory. By default, this file is called makefile or Makefile. See Section 19 for more information on make. See also the Nutshell Handbook, Managing Projects with make.

Options

-e

Override makefile assignments with environment variables.

-f makefile

Use makefile as the description file; a filename of - denotes standard input.

-i

Ignore command error codes (same as .IGNORE).

-k

Abandon the current entry when it fails, but keep working with unrelated entries.

-n

Print commands but don't execute (used for testing).

-p

Print macro definitions and target descriptions.

-q

Query; return 0 if file is up-to-date; nonzero otherwise.

-r

Do not use "default" rules.

-s

Do not display command lines (same as .SILENT).

-t

Touch the target files, causing them to be updated.

Previous: Reference: mailx | UNIX in a Nutshell: System V Edition | Next: Reference: makekey
Reference: mailx | Book Index | Reference: makekey


Reference: mcs

Previous: Reference: man Chapter 2
UNIX Commands 		Next: Reference: mesg

mcs

mcs [options] files

Manipulate the comment section. mcs is used to add to, compress, delete, or print a section of one or more ELF object files. The default section is .comment. If any input file is an archive, mcs acts on each component file and removes the archive symbol table (unless -p was the only option specified). Use ar s to regenerate the symbol table. At least one option must be supplied.

Options

-a string

Append string to the comment section of files.

-c

Compress the comment section of files and remove duplicate entries.

-d

Delete the comment section (including header).

-n name

Act on section name instead of .comment.

-p

Print the comment section on standard output.

-V

Print the version of mcs on standard error.

Example

mcs -p kernel.o	Print the comment section of kernel.o

Previous: Reference: man | UNIX in a Nutshell: System V Edition | Next: Reference: mesg
Reference: man | Book Index | Reference: mesg


Reference: mkdir

Previous: Reference: mesg Chapter 2
UNIX Commands 		Next: Reference: mkmsgs

mkdir

mkdir [options] directories

Create one or more directories. You must have write permission in the parent directory in order to create a directory. See also rmdir.

Options

-m mode

Set the access mode for new directories.

-p

Create intervening parent directories if they don't exist.

Examples

Create a read-only directory named personal:

mkdir -m 444 personal

The following sequence:

mkdir work; cd work
mkdir junk; cd junk
mkdir questions; cd ../..

could be accomplished by typing this:

mkdir -p work/junk/questions

Previous: Reference: mesg | UNIX in a Nutshell: System V Edition | Next: Reference: mkmsgs
Reference: mesg | Book Index | Reference: mkmsgs


Reference: mkmsgs

Previous: Reference: mkdir Chapter 2
UNIX Commands 		Next: Reference: more

mkmsgs

mkmsgs [options] string_file msg_file

Convert string_file (a list of text strings) into msg_file (the file whose format is readable by gettxt). The created msg_file is also used by the commands exstr and srchtxt.

Options

-i locale

Create msg_file in directory:

/usr/lib/locale/locale/LC_MESSAGES

For example, if string_file is a collection of error messages in German, you might specify locale as german.

-o

Overwrite existing msg_file.

Previous: Reference: mkdir | UNIX in a Nutshell: System V Edition | Next: Reference: more
Reference: mkdir | Book Index | Reference: more


Reference: nice

Previous: Reference: news Chapter 2
UNIX Commands 		Next: Reference: nl

nice

nice [option] command [arguments]

Execute a command and arguments with lower priority (i.e., be "nice" to other users).

Option

-n

Run command with a niceness of n (1-19); default is 10. Higher n means lower priority. A privileged user can raise priority by specifying a negative n (e.g., -5). nice works differently in the C shell (see Section 5). +n raises priority, -n lowers it, and 4 is the default.

Previous: Reference: news | UNIX in a Nutshell: System V Edition | Next: Reference: nl
Reference: news | Book Index | Reference: nl


Reference: nohup

Previous: Reference: nm Chapter 2
UNIX Commands 		Next: Reference: notify

nohup

nohup command [arguments] &

Continue to execute the named command and optional command arguments after you log out (make command immune to hangups; i.e., no hangup). In the C shell, nohup is built in. In the Bourne shell, nohup allows output redirection; output goes to nohup.out by default.

Previous: Reference: nm | UNIX in a Nutshell: System V Edition | Next: Reference: notify
Reference: nm | Book Index | Reference: notify


Reference: pack

Previous: Reference: openwin Chapter 2
UNIX Commands 		Next: Reference: page

pack

pack [options] files

Compact each file and place the result in file.z. The original file is replaced. To restore packed files to their original form, see pcat and unpack.

Options

-

Print number of times each byte is used, relative frequency, and byte code.

-f

Force the pack even when disk space isn't saved.

Previous: Reference: openwin | UNIX in a Nutshell: System V Edition | Next: Reference: page
Reference: openwin | Book Index | Reference: page


Reference: paste

Previous: Reference: passwd Chapter 2
UNIX Commands 		Next: Reference: pcat

paste

paste [options] files

Merge corresponding lines of one or more files into vertical columns, separated by a tab. See also cut, join, newform, and pr.

Options

-

Replace a filename with the standard input.

-d'char'

Separate columns with char instead of a tab. char can be any regular character or the following escape sequences:

\n

Newline

\t

Tab

\

Backslash

\0

Empty String

Note: You can separate columns with different characters by supplying more than one char.

-s

Merge subsequent lines from one file.

Examples

Create a three-column file from files x, y, and z:

paste x y z > file

List users in two columns:

who | paste - -

Merge each pair of lines into one line:

paste -s -d"\t\n" list

Previous: Reference: passwd | UNIX in a Nutshell: System V Edition | Next: Reference: pcat
Reference: passwd | Book Index | Reference: pcat


Reference: prof

Previous: Reference: printf Chapter 2
UNIX Commands 		Next: Reference: prs

prof

prof [options] [object_file]

Display the profile data for an object file. The file's symbol table is compared with profile file mon.out (previously created by the monitor function). Choose only one of the sort options -a, -c, -n, or -t . See also lprof and gprof.

Options

-a

List output by symbol address.

-c

List output by decreasing number of calls.

-g

Include non-global (static) function symbols.

-h

Suppress the report heading.

-l

Exclude non-global function symbols (the default).

-mpf

Use pf as the input profile file instead of mon.out.

-n

List by symbol name.

-o

Show addresses in octal (invalid with -x).

-s

Print a summary on standard error.

-t

List by decreasing total time percentage (the default).

-V

Print version information on standard error.

-x

Show addresses in hexadecimal (invalid with -o).

-z

Include zero usage calls.

Previous: Reference: printf | UNIX in a Nutshell: System V Edition | Next: Reference: prs
Reference: printf | Book Index | Reference: prs


Reference: prs

Previous: Reference: prof Chapter 2
UNIX Commands 		Next: Reference: ps

prs

prs [options] files

An SCCS command. See Section 17.

Previous: Reference: prof | UNIX in a Nutshell: System V Edition | Next: Reference: ps
Reference: prof | Book Index | Reference: ps


Reference: ps

Previous: Reference: prs Chapter 2
UNIX Commands 		Next: Reference: ptx

ps

ps [options]

Report on active processes. In options, list arguments should either be separated by commas or put in double quotes. In comparing the amount of output produced, note that -e > -d > -a and -l > -f. In the BSD version, options work much differently; you can also display data for a single process.

Options

-a

List all processes except group leaders and processes not associated with a terminal.

-c

List scheduler data set by priocntl.

-d

List all processes except session leaders.

-e

List all processes.

-f

Produce a full listing.

-glist

List data only for specified list of group leader ID numbers (i.e., processes with same ID and group ID).

-j

Print the process group ID and session ID.

-l

Produce a long listing.

-nlist

Use the alternate list of names (default is /unix); obsolete as of Release 4.

-plist

List data only for process IDs in list.

-slist

List data only for session leader IDs in list.

-tlist

List data only for terminals in list (e.g., tty1).

-ulist

List data only for usernames in list.

Previous: Reference: prs | UNIX in a Nutshell: System V Edition | Next: Reference: ptx
Reference: prs | Book Index | Reference: ptx


Reference: ptx

Previous: Reference: ps Chapter 2
UNIX Commands 		Next: Reference: pwd

ptx

ptx [options] [infile [outfile]]

Solaris 2.0 only. Generate a permuted index from infile and send output to outfile. (Standard input and output are the defaults.) To print the index, format the output file using the -mptx option to nroff or troff.

Options

-b file

In addition to using tab, space, and newline, use the characters in file as word separators.

-f

Fold uppercase and lowercase; i.e., ignore case when sorting keywords.

-g n

Set column gaps in output to n characters.

-i file

Ignore keywords listed in file. Default file is /usr/lib/eign.

-o file

Use only the words in file as keywords (inverse of -i).

-r

Use the first field of infile as a reference ID. This field does not get permuted but appears as the last field of the output.

-t

Prepare output for phototypesetting (default line length is 100 characters).

-w n

Produce output lines n characters wide (default is 72).

Example

Given a three-line input file ptx.in:

ar(1) ar: archive and library maintainer
at(1) at: execute commands at a later time
awk(1) awk: pattern scanning language

A permuted index could be generated as follows:

ptx -f -i ignore -w 80 -r ptx.in > ptx.out
troff -mptx options ptx.out | spooler

In this case, ptx merges uppercase and lowercase (-f) ignores a list of keywords (-i), uses 80-character output lines (-w), and appends the first word (the command name) as a section reference (-r).

Previous: Reference: ps | UNIX in a Nutshell: System V Edition | Next: Reference: pwd
Reference: ps | Book Index | Reference: pwd


Reference: pwd

Previous: Reference: ptx Chapter 2
UNIX Commands 		Next: Reference: rcp

pwd

pwd

Print the full pathname of the current directory. Note: The built-in versions pwd (Bourne and Korn shells) and dirs (C shell) are faster, so you might want to define the following C-shell alias:

alias pwd dirs -l

Previous: Reference: ptx | UNIX in a Nutshell: System V Edition | Next: Reference: rcp
Reference: ptx | Book Index | Reference: rcp


Reference: rcp

Previous: Reference: pwd Chapter 2
UNIX Commands 		Next: Reference: red

rcp

rcp [options] sources target

Copy files between machines. Both sources and target are filename specifications of the form host:pathname, where host: can be omitted for a file on the local machine. If no pathname is included in target, source files are placed in your home directory. If you have a different username on the remote host, specify the form username@hostname:file

Options

-p

Preserve in copies the modification times, access times, and modes of the source files.

-r

If target and sources are both directories, copy each subtree rooted at source.

Examples

Copy the local files junk and test to your home directory on machine hermes:

rcp junk test hermes:

Copy the local bin directory and all subdirectories to the /usr/tools directory on machine diana:

rcp -r /bin diana:/usr/tools

Copy all files in your home directory on machine hera, and put them in local directory /usr/daniel with times and modes unchanged:

rcp -p "hera:*" /usr/daniel

Quote the first argument to prevent filename expansion from occurring on the local machine.

Previous: Reference: pwd | UNIX in a Nutshell: System V Edition | Next: Reference: red
Reference: pwd | Book Index | Reference: red


Reference: regcmp

Previous: Reference: red Chapter 2
UNIX Commands 		Next: Reference: relogin

regcmp

regcmp [-] files

Stands for "regular expression compile." Compile the regular expressions in one or more files and place output in file.i (or in file.c if - is specified). The output is C source code, while the input entries in files are of the form:

C variable     "regular expression"

Previous: Reference: red | UNIX in a Nutshell: System V Edition | Next: Reference: relogin
Reference: red | Book Index | Reference: relogin


Reference: relogin

Previous: Reference: regcmp Chapter 2
UNIX Commands 		Next: Reference: reset

relogin

relogin [option] [terminal]

Change the login entry to reflect the current window running under layers. This ensures that commands like who and write use the correct login information. layers calls relogin automatically, but you may sometimes want to use relogin to change the destination window for write messages. terminal is the filename of the terminal to change; e.g., ttyp0.

Option

-s

Don't print error messages.

Previous: Reference: regcmp | UNIX in a Nutshell: System V Edition | Next: Reference: reset
Reference: regcmp | Book Index | Reference: reset


Reference: reset

Previous: Reference: relogin Chapter 2
UNIX Commands 		Next: Reference: rksh

reset

/usr/ucb/reset [options] [type]

Clear terminal settings. reset disables CBREAK mode, RAW mode, output delays, and parity checking. reset also restores undefined special characters and enables processing of newlines, tabs, and echoing. This command is useful when a program aborts in a way that leaves the terminal confused (e.g., keyboard input might not echo on the screen). To enter reset at the keyboard, you may need to use a linefeed instead of a carriage return. reset uses the same command-line arguments as tset.

Previous: Reference: relogin | UNIX in a Nutshell: System V Edition | Next: Reference: rksh
Reference: relogin | Book Index | Reference: rksh


Reference: rksh

Previous: Reference: reset Chapter 2
UNIX Commands 		Next: Reference: rlogin

rksh

rksh [options] [arguments]

Restricted version of ksh (the Korn shell), used in secure environments. rksh prevents you from changing out of the directory or from redirecting output. See Section 4.

Previous: Reference: reset | UNIX in a Nutshell: System V Edition | Next: Reference: rlogin
Reference: reset | Book Index | Reference: rlogin


Reference: rlogin

Previous: Reference: rksh Chapter 2
UNIX Commands 		Next: Reference: rm

rlogin

rlogin [options] host

Connect terminal on current local host system (i.e., login) to a remote host system. The .rhosts file in your home directory (on the remote host) lists the hostnames that you're allowed to connect to without giving a password.

Options

-8

Allow 8-bit data to pass, instead of 7-bit data.

-e c

Use escape character c (default is ~). You can type ~. to disconnect from remote host, though you'll exit more "cleanly" by logging out.

-l user

Log in to remote host as user, instead of using the name on the local host.

-L

Allow rlogin to run in litout mode.

Previous: Reference: rksh | UNIX in a Nutshell: System V Edition | Next: Reference: rm
Reference: rksh | Book Index | Reference: rm


Reference: rmdir

Previous: Reference: rmdel Chapter 2
UNIX Commands 		Next: Reference: rsh

rmdir

rmdir [options] directories

Delete the named directories (the name itself, not the contents). directories are deleted from the parent directory and must be empty (if not, rm -r can be used instead). See also mkdir.

Options

-p

Remove directories and any intervening parent directories that become empty as a result; useful for removing subdirectory trees.

-s

Suppress standard error messages caused by -p.

Previous: Reference: rmdel | UNIX in a Nutshell: System V Edition | Next: Reference: rsh
Reference: rmdel | Book Index | Reference: rsh


Reference: rsh

Previous: Reference: rmdir Chapter 2
UNIX Commands 		Next: Reference: rsh

rsh

rsh

Restricted version of sh (the Bourne shell) that is intended to be used where security is important. rsh prevents you from changing out of the directory or from redirecting output. See Section 4.

Previous: Reference: rmdir | UNIX in a Nutshell: System V Edition | Next: Reference: rsh
Reference: rmdir | Book Index | Reference: rsh


Reference: rsh

Previous: Reference: rsh Chapter 2
UNIX Commands 		Next: Reference: ruptime

rsh

rsh [options] host [command]

A BSD-derived command to invoke a remote shell. This command is usually found in /usr/ucb and should not be confused with rsh, the restricted shell. rsh connects to host and executes command. If command is not specified, rsh allows you to rlogin to host. If shell metacharacters need to be interpreted on the remote machine, enclose them in quotes. This command is sometimes called remsh.

Options

-l user

Connect to host with a login name of user.

-n

Divert input to /dev/null. Sometimes useful when piping rsh to a command that reads standard input but that might terminate before rsh.

Previous: Reference: rsh | UNIX in a Nutshell: System V Edition | Next: Reference: ruptime
Reference: rsh | Book Index | Reference: ruptime


Reference: sccsdiff

Previous: Reference: sccs Chapter 2
UNIX Commands 		Next: Reference: script

sccsdiff

sccsdiff -rsid1  -rsid2  [options] files

An SCCS command. See Section 17.

Previous: Reference: sccs | UNIX in a Nutshell: System V Edition | Next: Reference: script
Reference: sccs | Book Index | Reference: script


Reference: script

Previous: Reference: sccsdiff Chapter 2
UNIX Commands 		Next: Reference: sdb

script

script [option] [file]

Create a record of your login session, storing in file everything that displays on your screen. The default file is called typescript. script records non-printing characters as control characters and includes prompts. This command is useful for beginners or for saving output from a time-consuming command.

Option

-a

Append the script record to file.

Previous: Reference: sccsdiff | UNIX in a Nutshell: System V Edition | Next: Reference: sdb
Reference: sccsdiff | Book Index | Reference: sdb


Reference: sdb

Previous: Reference: script Chapter 2
UNIX Commands 		Next: Reference: sdiff

sdb

sdb [options] [objfile [corefile [dir_list]]]

A C and FORTRAN symbolic debugging program used to look at "core" files resulting from aborted programs. objfile contains an executable program, and corefile contains the core image produced when objfile was executed. a.out is the default objfile. core is the default corefile. The dir_list argument specifies the source directory for the files compiled to create objfile. See Section 20 for more information on sdb.

Options

-e

Ignore symbolic data; treat addresses as file offsets.

-s n

Don't stop processes that receive signal number n. See the signal system call for values of n. -s may be used more than once.

-V

Print version information (exit if no objfile is given).

-w

Make objfile and corefile writable.

-W

Suppress warning messages about older files.

Previous: Reference: script | UNIX in a Nutshell: System V Edition | Next: Reference: sdiff
Reference: script | Book Index | Reference: sdiff


Reference: sdiff

Previous: Reference: sdb Chapter 2
UNIX Commands 		Next: Reference: sed

sdiff

sdiff [options] file1 file2

Produce a side-by-side comparison of file1 with file2. Output is:

text text

Identical lines.

text <

Line exists only in file1.

> text

Line exists only in file2.

text | text

Lines are different.

Options

-l

List only lines of file1 that are identical.

-o outfile

Send identical lines of file1 and file2 to outfile; print line differences and edit outfile by entering, when prompted, the following commands:

e

Edit an empty file.

e b

Edit both left and right columns.

e l

Edit left column.

e r

Edit right column.

l

Append left column to outfile.

q

Exit the editor.

r

Append right column to outfile.

s

Silent mode; do not print identical lines.

v

Turn off "silent mode."

-s

Do not print identical lines.

-wn

Set line length to n (default is usually 130).

Example

Show differences using 80 columns, and ignore identical lines:

sdiff -s -w80 list.1 list.2

Previous: Reference: sdb | UNIX in a Nutshell: System V Edition | Next: Reference: sed
Reference: sdb | Book Index | Reference: sed


Reference: sed

Previous: Reference: sdiff Chapter 2
UNIX Commands 		Next: Reference: sh

sed

sed [options] [files]

Stream editor-edit one or more files without user interaction. See Section 10 for more information on sed.

Options

-e 'instruction'

Apply the editing instruction to the files.

-f script

Apply the set of instructions from the editing script.

-n

Suppress default output.

Previous: Reference: sdiff | UNIX in a Nutshell: System V Edition | Next: Reference: sh
Reference: sdiff | Book Index | Reference: sh


Reference: sh

Previous: Reference: sed Chapter 2
UNIX Commands 		Next: Reference: shl

sh

sh [options] [arguments]

The standard command interpreter (or Bourne shell) that executes commands from a terminal or a file. See Section 4 for more information on the Bourne shell, including command-line options.

Previous: Reference: sed | UNIX in a Nutshell: System V Edition | Next: Reference: shl
Reference: sed | Book Index | Reference: shl


Reference: shl

Previous: Reference: sh Chapter 2
UNIX Commands 		Next: Reference: shutdown

shl

shl

Control more than one shell (layer) from a single terminal. From the shl prompt level, you can issue the commands listed below (abbreviating them to any unique prefix if desired). The name text string should not exceed eight characters. See also layers.

block name [name2...]

Block the output for each layer name (same as stty loblk).

create [name]

Create the layer name (no more than seven total).

delete name [name2...]

Delete the layer name.

help or ?

Provide shl command syntax.

layers [-l] [name...]

Print information about layers. -l provides a ps-like display.

name

Make layer name be the current level.

quit

Exit shl and kill all the layers.

resume [name]

Return to latest layer or to layer name.

toggle

Flip back to the previous layer.

unblock name [name2...]

Do not block output for each layer name (same as stty -loblk).

Previous: Reference: sh | UNIX in a Nutshell: System V Edition | Next: Reference: shutdown
Reference: sh | Book Index | Reference: shutdown


Reference: sleep

Previous: Reference: size Chapter 2
UNIX Commands 		Next: Reference: soelim

sleep

sleep seconds

Wait a specified number of seconds before executing another command. Often used in shell scripts.

Previous: Reference: size | UNIX in a Nutshell: System V Edition | Next: Reference: soelim
Reference: size | Book Index | Reference: soelim


Reference: srchtxt

Previous: Reference: split Chapter 2
UNIX Commands 		Next: Reference: strings

srchtxt

srchtxt [options] [regexp]

A grep-like utility to search message files for text strings that match regular expression regexp. srchtxt is one of the message manipulation commands like gettxt and mkmsgs. If no regexp is used, srchtxt displays all message strings from the specified files.

Options

.hw locale

-l locale

Search files that reside in the directory /usr/lib/locale/locale/LC_MESSAGES, where locale is the language in which the message strings have been written. The default locale is set by environment variable LC_MESSAGES or LANG. If neither is set, srchtxt searches directory /usr/lib/locale/C/LC_MESSAGES.

-m msgfiles

Search for strings in one or more comma-separated msgfiles. Specifying a pathname for msgfiles overrides the -l option.

-s

Don't print message numbers for strings.

Previous: Reference: split | UNIX in a Nutshell: System V Edition | Next: Reference: strings
Reference: split | Book Index | Reference: strings


Reference: strings

Previous: Reference: srchtxt Chapter 2
UNIX Commands 		Next: Reference: strip

strings

strings [options] files

endings::newline/null sequence endings" Search object or binary files for sequences of four or more printable characters that end with a newline or null. See also od.

Options

-a

Search entire file, not just the initialized data portion of object files. Can also specify this option as -.

-o

Display the string's offset position before the string.

-n n

Minimum string length is n (default is 4). Can also specify this option as -n.

Previous: Reference: srchtxt | UNIX in a Nutshell: System V Edition | Next: Reference: strip
Reference: srchtxt | Book Index | Reference: strip


Reference: strip

Previous: Reference: strings Chapter 2
UNIX Commands 		Next: Reference: stty

strip

strip [options] files

Remove information from ELF object files or archive files, thereby reducing file sizes and freeing disk space. The following items can be removed:

1)

Symbol table.

2)

Debugging information.

3)

Line number information.

4)

Static symbol information.

5)

External symbol information.

6)

Block delimiters.

7)

Relocation bits.

Options

-b

Don't strip items 4, 5, and 6.

-l

Strip only item 3 (line number information).

-r

Don't strip items 4, 5, and 7.

-V

Print the version number of strip on standard error.

-x

Strip only items 2 and 3.

Previous: Reference: strings | UNIX in a Nutshell: System V Edition | Next: Reference: stty
Reference: strings | Book Index | Reference: stty


Reference: stty

Previous: Reference: strip Chapter 2
UNIX Commands 		Next: Reference: su

stty

stty [options] [modes]

Set terminal I/O options for the current device. Without options, stty reports the terminal settings, where a ^ indicates the CONTROL key and ^` indicates a null value. Most modes can be switched using an optional - (shown in brackets). The corresponding description is also shown in brackets. As a privileged user, you can set or read settings from another device using the syntax:

stty [options] [modes] < device

Options

-a

Report all option settings.

-g

Report current settings.

control modes

0

Hang up phone.

n

Set terminal baud rate to n (e.g., 2400).

[-]clocal

[Enable]disable modem control.

[-]cread

[Disable]enable the receiver.

csn

Select character size (5-8).

[-]cstopb

[One]two stop bits per character.

[-]hup

[Do not]hang up connection on last close.

[-]hupcl

Same as previous.

ispeed n

Set terminal input baud rate to n.

[-]loblk

[Do not]block layer output.

ospeed n

Set terminal output baud rate to n.

[-]parenb

[Disable]enable parity generation and detection.

[-]parext

[Disable]enable extended parity generation and detection for mark and space parity.

[-]parodd

Use [even]odd parity.

Input modes

[-]brkint

[Do not]signal INTR on break.

[-]icrnl

[Do not]map carriage return (^M) to newline (^J) on input.

[-]ignbrk

[Do not]ignore break on input.

[-]igncr

[Do not]ignore carriage return on input.

[-]ignpar

[Do not]ignore parity errors.

[-]imaxbel

[Do not]echo BEL when input line is too long.

[-]inlcr

[Do not]map newline to carriage return on input.

[-]inpck

[Disable]enable input parity checking.

[-]istrip

[Do not]strip input characters to seven bits.

[-]iuclc

[Do not]map uppercase to lowercase on input.

[-]ixany

Allow [XON]any character to restart output.

[-]ixoff

[Do not]send START/STOP characters when queue is nearly empty/full.

[-]ixon

[Disable]enable START/STOP output control.

[-]parmrk

[Do not]mark parity errors.

Output modes

bsn

Select style of delay for backspaces (0 or 1).

crn

Select style of delay for carriage returns (0-3).

ffn

Select style of delay for formfeeds (0 or 1).

nln

Select style of delay for linefeeds (0 or 1).

[-]ocrnl

[Do not]map carriage return to newline on output.

[-]ofdel

Set fill character to [NULL]DEL.

[-]ofill

Delay output with [timing]fill characters.

[-]olcuc

[Do not]map lowercase to uppercase on output.

[-]onlcr

[Do not]map newline to carriage return-newline on output.

[-]onlret

[Do not]perform carriage return after newline.

[-]onocr

[Do not]output carriage returns at column zero.

[-]opost

[Do not]postprocess output; ignore all other output modes.

tabn

Select style of delay for horizontal tabs (0-3).

vtn

Select style of delay for vertical tabs (0 or 1).

Local modes

[-]echo

[Do not]echo every character typed.

[-]echoctl

[Do not]echo control characters as ^char, delete as ^?.

[-]echoe

[Do not]echo ERASE character as BS-space-BS string.

[-]echok

[Do not]echo newline after KILL character.

[-]echoke

[Do not]BS-SP-BS erase entire line on line kill.

[-]echonl

[Do not]echo newline (^J).

[-]echoprt

[Do not]echo erase character as character is "erased."

[-]flusho

Output is [not] being flushed.

[-]icanon

[Disable]enable canonical input (ERASE and KILL processing).

[-]iexten

[Disable]enable extended functions for input data.

[-]isig

[Disable]enable checking of characters against INTR, QUIT, and SWITCH.

[-]noflsh

[Enable]disable flush after INTR, QUIT, or SWITCH.

[-]pendin

[Do not]retype pending input at next read or input character.

[-]stappl

[Line]application mode on a synchronous line.

[-]stflush

[Disable]enable flush on synchronous line.

[-]stwrap

[Enable]disable truncation on synchronous line.

[-]tostop

[Do not]send SIGTTOU when background processes write to the terminal.

[-]xcase

[Do not]change case on local output.

Control assignments

ctrl-char c

Set control character to c. ctrl-char is: ctab, discard, dsusp, eof, eol, eol2, erase, intr, kill, lnext, quit, reprint, start, stop, susp, swtch, werase.

min, time n

Set min or time to n.

line i

Set line discipline to i (1-126).

Combination modes

async

Set normal asynchronous communications.

cooked

Same as -raw.

[-]evenp

Same as [-]parenb and cs[8]7.

ek

Reset ERASE and KILL characters to # and @.

[-]lcase

[Un]set xcase, iuclc, and olcuc.

[-]LCASE

Same as [-]lcase.

[-]markp

[Disable]enable parenb, parodd, and parext and set cs[8]7.

[-]nl

[Un]set icrnl and onlcr. -nl also unsets inlcr, igncr, ocrnl, and onlret.

[-]oddp

Same as [-]parenb, [-]parodd, and cs7[8].

[-]parity

Same as [-]parenb and cs[8]7.

[-]raw

[Disable]enable raw input and output (no ERASE, KILL, INTR, QUIT, EOT, SWITCH, or output postprocessing).

sane

Reset all modes to reasonable values.

[-]spacep

[Disable]enable parenb and parext and set cs[8]7.

[-]tabs

[Expand to spaces]preserve output tabs.

term

Set all modes suitable for terminal type term (tty33, tty37, vt05, tn300, ti700, or tek).

Hardware flow control modes

[-]rtsxoff

[Disable]enable RTS on input.

[-]ctsxon

[Disable]enable CTS on output.

[-]dtrxoff

[Disable]enable DTR on input.

[-]cdxon

[Disable]enable CD on output.

[-]isxoff

[Disable]enable isochronous on input.

Clock modes

[x|r]cibrg

Get the transmit|receive clock from internal baud rate generator.

[x|r]ctset

Get the transmit|receive clock from transmitter timing-lead, circuit 114, pin 15.

[x|r]crset

Get the transmit|receive clock from receiver timing-lead, circuit 115, pin 17.

For modes beginning with t, pin is transmitter timing-lead, circuit 113, pin 24. For modes beginning with r, pin is receiver timing-lead, circuit 128, no pin.

[t|r]setcoff

No transmitter|receiver timing clock.

[t|r]setcrbrg

Send receive baud rate generator to pin.

[t|r]setctbrg

Send transmit baud rate generator to pin.

[t|r]setctset

Send transmitter timing to pin.

[t|r]setcrset

Send receiver timing to pin.

Window size

columns n

Set size to n columns.

rows n

Set size to n rows.

xpixels n

Set size to n pixels across.

ypixels n

Set size to n pixels up and down.

Previous: Reference: strip | UNIX in a Nutshell: System V Edition | Next: Reference: su
Reference: strip | Book Index | Reference: su


Reference: sum

Previous: Reference: su Chapter 2
UNIX Commands 		Next: Reference: tabs

sum

sum [option] file

Calculate and print a checksum and the number of (512-byte) blocks for file. Useful for verifying data transmission.

Option

-r

Use an alternate checksum algorithm; this produces the same results as the BSD version of sum.

Previous: Reference: su | UNIX in a Nutshell: System V Edition | Next: Reference: tabs
Reference: su | Book Index | Reference: tabs


Reference: talk

Previous: Reference: tail Chapter 2
UNIX Commands 		Next: Reference: tar

talk

talk user [@hostname] [tty]

Exchange typed communication with another user who is on the local machine or on machine hostname. talk might be useful when you're logged in via modem and need something quickly, making it inconvenient to telephone or send e-mail. talk splits your screen into two windows. When connection is established, you type in the top half while user's typing appears in the bottom half. Type CTRL-L to redraw the screen and CTRL-D (or interrupt) to exit. If user is logged in more than once, use tty to specify the terminal line.

Previous: Reference: tail | UNIX in a Nutshell: System V Edition | Next: Reference: tar
Reference: tail | Book Index | Reference: tar


Reference: tar

Previous: Reference: talk Chapter 2
UNIX Commands 		Next: Reference: tbl

tar

tar [options] [files]

Copy files to or restore files from tape. If any files are directories, tar acts on the entire subtree. Options need not be preceded by -. Note that options are supplied as one group, with any arguments placed afterward in corresponding order.

Function options (choose one)

c

Create a new tape.

r

Append files to tape.

t

Print the names of files if they are stored on the tape (if files not specified, print names of all files).

u

Add files if not on tape or if modified.

x

Extract files from tape (if files not specified, extract all files).

Options

b n

Use blocking factor n (default is 1; maximum is 20).

f arch

Store files in or extract files from archive arch; arch is usually a device name (default is /dev/mt0). If arch is -, standard input or output is used as appropriate (e.g., when piping a tar archive to a remote host).

l

Print error messages about links it can't find.

L

Follow symbolic links.

m

Do not restore file modification times; update them to the time of extraction.

o

Change ownership of extracted files to that of user running program.

v

Print function letter (x for extraction or a for archive) and name of files.

w

Wait for user confirmation (y).

n[c]

Select tape drive n and use speed c. n is 0-7 (default is 0); c is l (low) h (high) m (medium, the default). Used to modify arch.

Examples

Create an archive of /bin and /usr/bin (c), show the command working (v), and store on the tape in /dev/rmt0:

tar cvf /dev/rmt0 /bin /usr/bin

List the tape's contents in a format like ls -l:

tar tvf /dev/rmt0

Extract the /bin directory:

tar xvf /dev/rmt0 /bin

Create an archive of the current directory, and store it in a file backup.tar on the system.

tar cvf - `find . -print` > backup.tar

(The - tells tar to store the directory on standard output, which is then redirected.)

Previous: Reference: talk | UNIX in a Nutshell: System V Edition | Next: Reference: tbl
Reference: talk | Book Index | Reference: tbl


Reference: tee

Previous: Reference: tbl Chapter 2
UNIX Commands 		Next: Reference: telnet

tee

tee [options] [files]

Duplicate the standard input; send one copy to standard output and another copy to files.

Options

-a

Append output to files.

-i

Ignore all interrupts.

Examples

Display a who listing on the screen, and store it in two files:

who | tee userlist ttylist

Display misspelled words, and add them to existing typos:

spell ch02 | tee -a typos

Previous: Reference: tbl | UNIX in a Nutshell: System V Edition | Next: Reference: telnet
Reference: tbl | Book Index | Reference: telnet


Reference: tr

Previous: Reference: tput Chapter 2
UNIX Commands 		Next: Reference: troff

tr

tr [options] [string1 [string2]]

Copy standard input to standard output, performing substitution of characters from string1 to string2 or deletion of characters in string1.

Options

-c

Complement characters in string1 with ASCII 001-377.

-d

Delete characters in string1 from output.

-s

Squeeze out repeated output characters in string2.

Examples

Change uppercase to lowercase in a file:

cat file | tr `[A-Z]` `[a-z]`

Turn spaces into newlines (ASCII code 012):

tr ' ' '\012' <file

Strip blank lines from file and save in new.file (or use \011 to change successive tabs into one tab):

cat file | tr -s "" "/012" > new.file

Delete colons from file; save result in new.file:

tr -d : <file > new.file

Previous: Reference: tput | UNIX in a Nutshell: System V Edition | Next: Reference: troff
Reference: tput | Book Index | Reference: troff


Reference: truss

Previous: Reference: true Chapter 2
UNIX Commands 		Next: Reference: tset

truss

truss [options] arguments

Trace system calls, signals, and machine faults while executing arguments. arguments is either a UNIX command or, if -p is specified, a list of process IDs representing the processes to run. The options -m, -t, -v, -x, -s, -r, and -w accept a comma-separated list of arguments. A ! reverses the sense of the list, telling truss to ignore those elements of the list during the trace. (In the C shell, use a backslash before !.) The optional ! and corresponding description are shown in brackets.

Options

-a

Display parameters passed by each exec call.

-c

Count the traced items rather than listing them.

-e

Display values of environment variables passed by each exec call.

-f

Follow child processes. Useful for tracing shell scripts.

-i

List sleeping system calls only once, upon completion.

-m[!]faults

Trace [exclude from trace] the list of machine faults. faults are names or numbers, as listed in <sys/fault.h> (default is -mall -m!fltpage).

-o outfile

Send trace output to outfile, not standard error.

-p

Trace one or more process IDs instead of a command.

-r[!]file_descriptors

Display [don't display] the I/O buffer of read system calls for file_descriptors (default is -r!all).

-s[!]signals

Trace [exclude from trace] the list of signals. signals are names or numbers, as listed in <sys/signal.h> (default is -sall).

-t[!]system_calls

Trace [exclude from trace] the list of system_calls. system_calls are names or numbers, as listed in Section 2, "System Calls," of the UNIX Programmer's Reference Manual (default is -tall).

-v[!]system_calls

Verbose mode. Same as -t, but list also the contents of any structures passed to system_calls (default is -v!all).

-w[!]file_descriptors

Display [don't display] the I/O buffer of write system calls for file_descriptors (default is -w!all).

-x[!]system_calls

Same as -t, but display the system call arguments as raw code (hexadecimal) (default is -x!all).

Examples

Trace system calls open and close for lp command:

truss -t open,close lp files > truss.out

Trace the make command, including its child processes, and store the output in make.trace:

truss -f -o make.trace make target

Previous: Reference: true | UNIX in a Nutshell: System V Edition | Next: Reference: tset
Reference: true | Book Index | Reference: tset


Reference: tset

Previous: Reference: truss Chapter 2
UNIX Commands 		Next: Reference: tsort

tset

/usr/ucb/tset [options] [type]

Set terminal modes. Without arguments, the terminal is reinitialized according to the TERM environment variable. tset is typically used in startup scripts (.profile or .login). type is the terminal type; if preceded by a ?, tset prompts the user to enter a different type, if needed. Press RETURN to use the default value, type. See also reset.

Options

-

Print terminal name on standard output; useful for passing this value to TERM.

-ec

Set erase character to c; default is ^H (backspace).

-ic

Set interrupt character to c (default is ^C).

-I

Do not output terminal initialization setting.

-k c

Set line-kill character to c (default is ^U).

-m[port[baudrate]:tty]

Declare terminal specifications. port is the port type (usually dialup or plugboard). tty is the terminal type; it can be preceded by ? as above. baudrate checks the port speed and can be preceded by any of these characters:

>

Port must be greater than baudrate.

<

Port must be less than baudrate.

@

Port must transmit at baudrate.

!

Negate a subsequent >, <, or @ character.

-n

Initialize new tty driver modes. Useless because of redundancy with stty new.

-Q

Do not print "Erase set to" and "Kill set to" messages.

-r

Report the terminal type.

-s

Return the values of TERM assignments to shell environment. This is a commonly done via eval \`tset -s\` (in the C shell, you would surround this with the commands set noglob and unset noglob).

Examples

Set TERM to wy50:

eval `tset -s wy50`

Prompt user for terminal type (default will be vt100):

eval `tset -Qs -m '?vt100'`

Similar to above, but the baudrate must exceed 1200:

eval `tset -Qs -m '>1200:?xterm'`

Set terminal via modem; the ?$TERM checks that the terminal type is set (C shell only):

eval `tset -s -m dialup:'?vt100' "?$TERM"`

Previous: Reference: truss | UNIX in a Nutshell: System V Edition | Next: Reference: tsort
Reference: truss | Book Index | Reference: tsort


Reference: tsort

Previous: Reference: tset Chapter 2
UNIX Commands 		Next: Reference: tty

tsort

tsort [file]

Perform a topological sort on file. Typically used to reorganize an archive library for more efficient handling by ar or ld. Not very useful.

Example

Find the ordering relationship of all object files, and sort them for access by ld:

lorder *.o | tsort

Previous: Reference: tset | UNIX in a Nutshell: System V Edition | Next: Reference: tty
Reference: tset | Book Index | Reference: tty


Reference: tty

Previous: Reference: tsort Chapter 2
UNIX Commands 		Next: Reference: umask

tty

tty [options]

Print the device name of your terminal. This is useful for shell scripts and often for commands that need device information.

Options

-l

Print the synchronous line number.

-s

Return only the codes: 0 (a terminal), 1 (not a terminal), 2 (invalid options used).

Previous: Reference: tsort | UNIX in a Nutshell: System V Edition | Next: Reference: umask
Reference: tsort | Book Index | Reference: umask


Reference: umask

Previous: Reference: tty Chapter 2
UNIX Commands 		Next: Reference: uname

umask

umask [value]

Print the current value of the file creation mode mask, or set it to value, a three-digit octal code specifying the read-write-execute permissions to be turned off. This is the opposite of chmod. Usually used in .login or .profile. umask is available as a built-in command in the Bourne and C shells (see Sections 4 and 5).

umask Number | File Permission | Directory Permission
0 | rw- | rwx
1 | rw- | rw-
2 | r-- | r-x
3 | r-- | r--
4 | -w- | -wx
5 | -w- | -w-
6 | -- | -x
7 | -- | --

Examples

Turn off write permission for others:

umask 002	Produces file permission -rw-rw-r-

Turn off all permissions for group and others:

umask 077	Produces file permission -rw----

Note that you can omit leading zeroes.

Previous: Reference: tty | UNIX in a Nutshell: System V Edition | Next: Reference: uname
Reference: tty | Book Index | Reference: uname


Reference: uncompress

Previous: Reference: uname Chapter 2
UNIX Commands 		Next: Reference: unget

uncompress

uncompress [option] [files]

Restore the original file compressed by compress. The .Z extension is implied, so it can be omitted when specifying files.

Option

-c

Same as zcat (write to standard output without changing files).

Previous: Reference: uname | UNIX in a Nutshell: System V Edition | Next: Reference: unget
Reference: uname | Book Index | Reference: unget


Reference: units

Previous: Reference: uniq Chapter 2
UNIX Commands 		Next: Reference: unpack

units

units

Interactively supply a formula to convert a number from one unit to another. The file /usr/lib/units gives a complete list of the units. Use EOF to exit.

Previous: Reference: uniq | UNIX in a Nutshell: System V Edition | Next: Reference: unpack
Reference: uniq | Book Index | Reference: unpack


Reference: uucp

Previous: Reference: users Chapter 2
UNIX Commands 		Next: Reference: uudecode

uucp

uucp [options] [source!]file [destination!]file

Copy a file (or group of files) from the source to the destination. The source and destination can be remote systems. The destination file can be a directory.

Options

-c

Do not copy files to the spool directory (the default).

-C

Copy files to the spool directory for transfer.

-d

Make directories for the copy when they don't exist (the default).

-f

Do not make directories when they don't exist.

-gx

Set grade (priority) of job. x is typically a single letter or digit, where a and 1 give the highest transfer priority. Use uuglist to show values for x.

-j

Print the uucp job number.

-m

When copy is complete, send mail to person who issued uucp command.

-nuser

When copy is complete, send mail to user.

-r

Queue job, but don't start transfer program (uucico).

-sfile

Send transfer status to file (a full pathname); overrides -m.

-xn

Debug at level n (0-9); higher numbers give more output.

Example

This shell script sends a compressed file to system orca:

cat send_it
compress $1
uucp -C -n$2 -m $1.Z orca\!/usr/spool/uucppublic
uncompress $1

With -C, the transfer is made on a copy in the spool directory. (Normally, uucp gets the file from its original location, so you couldn't rename it or uncompress it until the call goes through.) The script also notifies sender and recipient when the transfer finishes. Here's a sample run:

send_it chapter1 bob

Previous: Reference: users | UNIX in a Nutshell: System V Edition | Next: Reference: uudecode
Reference: users | Book Index | Reference: uudecode


Reference: uux

Previous: Reference: uuto Chapter 2
UNIX Commands 		Next: Reference: vacation

uux

uux [options] [[sys]!command]

Gather files from various systems and execute command on the specified machine sys. uux also recognizes the uucp options -c, -C, -g, -r, -s, and -x.

Options

-

Same as -p (pass standard input to command).

-auser

Notify user upon completion (see -z).

-b

Print the standard input when the exit status indicates an error.

-j

Print the uux job number.

-n

Do not send mail if command fails.

-p

Pass the standard input to command.

-z

Notify invoking user upon successful completion.

Previous: Reference: uuto | UNIX in a Nutshell: System V Edition | Next: Reference: vacation
Reference: uuto | Book Index | Reference: vacation


Reference: vc

Previous: Reference: val Chapter 2
UNIX Commands 		Next: Reference: vedit

vc

vc [options] [keyword=value ...]

Copy lines from standard input to standard output under control of the vc keywords and arguments within the standard input. This command is obsolete.

Options

-a

Replace control keywords in all lines, including text lines.

-ck

Use k instead of : as the control character.

-s

Suppress warning messages.

-t

If any control characters are found before the first tab in the file, remove all characters up to the first tab.

Previous: Reference: val | UNIX in a Nutshell: System V Edition | Next: Reference: vedit
Reference: val | Book Index | Reference: vedit


Reference: w

Previous: Reference: view Chapter 2
UNIX Commands 		Next: Reference: wait

w

/usr/ucb/w [options] [user]

Print summaries of system usage, currently logged-in users, and what they are doing. w is essentially a combination of uptime, who, and ps -a. Display output for one user by specifying user.

Options

-h

Suppress headings and uptime information.

-l

Display in long format (the default).

-s

Display in short format.

Previous: Reference: view | UNIX in a Nutshell: System V Edition | Next: Reference: wait
Reference: view | Book Index | Reference: wait


Reference: wait

Previous: Reference: w Chapter 2
UNIX Commands 		Next: Reference: wall

wait

wait [n]

Wait for all background processes to complete, and report their termination status. Used in shell scripts. If n is specified, wait only for the process with process ID n.

Previous: Reference: w | UNIX in a Nutshell: System V Edition | Next: Reference: wall
Reference: w | Book Index | Reference: wall


Reference: wall

Previous: Reference: wait Chapter 2
UNIX Commands 		Next: Reference: wc

wall

wall
message

Send a message to all users. End message with EOF. This is typically used by a privileged user to inform users of a system shutdown.

Previous: Reference: wait | UNIX in a Nutshell: System V Edition | Next: Reference: wc
Reference: wait | Book Index | Reference: wc


Reference: wc

Previous: Reference: wall Chapter 2
UNIX Commands 		Next: Reference: what

wc

wc [options] [files]

Print a character, word, and line count for files. If no files are given, read standard input. See other examples under ls and sort.

Options

-c

Print character count only.

-l

Print line count only.

-w

Print word count only.

Examples

Count the number of users logged in:

who | wc -l

Count the words in three essay files:

wc -w essay.[123]

Count lines in variable $file (don't display filename):

wc -l <$file

Previous: Reference: wall | UNIX in a Nutshell: System V Edition | Next: Reference: what
Reference: wall | Book Index | Reference: what


Reference: whatis

Previous: Reference: what Chapter 2
UNIX Commands 		Next: Reference: which

whatis

/usr/ucb/whatis commands

Look up one or more commands in the on-line manual pages, and display a brief description. Same as man -f. See also apropos.

Previous: Reference: what | UNIX in a Nutshell: System V Edition | Next: Reference: which
Reference: what | Book Index | Reference: which


Reference: write

Previous: Reference: whois Chapter 2
UNIX Commands 		Next: Reference: xargs

write

write user [tty]
message

Initiate or respond to an interactive conversation with user. A write session is terminated with EOF. If the user is logged in to more than one terminal, specify a tty number.

Previous: Reference: whois | UNIX in a Nutshell: System V Edition | Next: Reference: xargs
Reference: whois | Book Index | Reference: xargs


Reference: xargs

Previous: Reference: write Chapter 2
UNIX Commands 		Next: Reference: yacc

xargs

xargs [options] [command]

Execute command (with any initial arguments), but read remaining arguments from standard input instead of specifying them directly. xargs passes these arguments in several bundles to command, allowing command to process more arguments than it could normally handle at once. The arguments are typically a long list of filenames (generated by ls or find, for example) that get passed to xargs via a pipe.

Options

-estring

Stop passing arguments when argument string is encountered (default is underscore).

-i

Pass arguments to command, replacing instances of { } on the command line with the current line of input.

-ln

Execute command for n lines of arguments.

-nn

Execute command with up to n arguments.

-p

Prompt for a y to confirm each execution of command.

-sn

Each argument list can contain up to n characters (470 is the default and the maximum value).

-t

Echo each command before executing.

-x

Exit if argument list exceeds n characters (from -s); -x takes effect automatically with -i and -l.

Examples

grep for pattern in all files on the system:

find / -print | xargs grep pattern > out &

Run diff on file pairs (e.g., f1.a and f1.b, f2.a and f2.b ...):

echo $* | xargs -n2 diff

The previous line would be invoked as a shell script, specifying filenames as arguments. Display file, one word per line (same as deroff -w):

cat file | xargs -n1

Move files in olddir to newdir, showing each command:

ls olddir | xargs -i -t mv olddir/{ } newdir/{ }

Previous: Reference: write | UNIX in a Nutshell: System V Edition | Next: Reference: yacc
Reference: write | Book Index | Reference: yacc


Reference: yacc

Previous: Reference: xargs Chapter 2
UNIX Commands 		Next: Reference: zcat

yacc

yacc [options] file

Given a file containing context-free grammar, convert file into tables for subsequent parsing and send output to y.tab.c. This command name stands for yet another compiler-compiler. See also lex and the Nutshell Handbook lex & yacc.

Options

-d

Generate y.tab.h, producing #define statements that relate yacc's token codes to the token names declared by the user.

-l

Exclude #line constructs from code produced in y.tab.c. (Use after debugging is complete.)

-Qc

Place version information about yacc in y.tab.c (if c = y) or suppress information (if c = n, the default).

-t

Compile runtime debugging code by default.

-v

Generate y.output, a file containing diagnostics and notes about the parsing tables.

-V

Print the version of yacc on standard error.

Previous: Reference: xargs | UNIX in a Nutshell: System V Edition | Next: Reference: zcat
Reference: xargs | Book Index | Reference: zcat


Reference: zcat

Previous: Reference: yacc Chapter 2
UNIX Commands 		Next: 2. UNIX Commands

zcat

zcat [files]

Uncompress one or more .Z files to the standard output, leaving files unchanged. See compress.

Previous: Reference: yacc | UNIX in a Nutshell: System V Edition | Next: 2. UNIX Commands
Reference: yacc | Book Index | 2. UNIX Commands


Reference: #

Previous: 4.6 Built-in Commands (Bourne and Korn Shell) Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: #!shell

#

#

Ignore all text that follows on the same line. # is used in shell scripts as the comment character and is not really a command. (Take care when commenting a Bourne shell script. A file that has # as its first character is sometimes interpreted as a C shell script.)

Previous: 4.6 Built-in Commands (Bourne and Korn Shell) | UNIX in a Nutshell: System V Edition | Next: Reference: #!shell
4.6 Built-in Commands (Bourne and Korn Shell) | Book Index | Reference: #!shell


Reference: #!shell

Previous: Reference: # Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: :

#!shell

#!shell

Used as the first line of a script to invoke the named shell (with optional arguments). Not supported in all shells. For example:

#!/bin/sh -v

Previous: Reference: # | UNIX in a Nutshell: System V Edition | Next: Reference: :
Reference: # | Book Index | Reference: :


Reference: :

Previous: Reference: #!shell Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: .

:

:

Null command. Returns an exit status of 0. Sometimes used as the first character in a file to denote a Bourne shell script. See example below and under case. In the Korn shell, shell variables can be placed after the : to expand them to their values.

Example

Check whether someone is logged in:

if who | grep $1 > /dev/null
then :	# do nothing
    # if pattern is found
else echo "User $1 is not logged in"
fi

Previous: Reference: #!shell | UNIX in a Nutshell: System V Edition | Next: Reference: .
Reference: #!shell | Book Index | Reference: .


Reference: .

Previous: Reference: : Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: [[ ]]

.

. file [arguments]

Read and execute lines in file. file does not have to be executable but must reside in a directory searched by PATH. The Korn shell supports arguments that are stored in the positional parameters.

Previous: Reference: : | UNIX in a Nutshell: System V Edition | Next: Reference: [[ ]]
Reference: : | Book Index | Reference: [[ ]]


Reference: [[ ]]

Previous: Reference: . Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: name

[[ ]]

[[expression]]

Korn shell only. Same as test expression or [expression], except that [[ ]] allows additional operators. Word splitting and filename expansion are disabled. Note that the brackets ([ ]) are typed literally.

Additional operators

&&

Logical AND of test expressions.

||

Logical OR of test expressions.

>

First string is lexically "greater than" the second.

<

First string is lexically "less than" the second.

Previous: Reference: . | UNIX in a Nutshell: System V Edition | Next: Reference: name
Reference: . | Book Index | Reference: name


Reference: name

Previous: Reference: [[ ]] Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: alias

name

name () { commands; }

Define name as a function. Syntax can be written on one line or across many. Since the Bourne shell has no aliasing capability, simple functions can serve as aliases. The Korn shell provides the function command, an alternate form that works the same way.

Example

$ count () {
> ls | wc -l
> }

When issued at the command line, count will now display the number of files in the current directory.

Previous: Reference: [[ ]] | UNIX in a Nutshell: System V Edition | Next: Reference: alias
Reference: [[ ]] | Book Index | Reference: alias


Reference: alias

Previous: Reference: name Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: autoload

alias

alias [options] [name[='cmd']]

Korn shell only. Assign a shorthand name as a synonym for cmd. If ='cmd' is omitted, print the alias for name; if name is also omitted, print all aliases. See also unalias. The aliases below are built into the Korn shell. Some use names of existing Bourne shell or C shell commands (which points out the similarities among the shells).

autoload='typeset -fu'
echo='print -'
false='let 0'
function='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
nohup='nohup '
pwd='print -r - $PWD'
r='fc -e -'
true=':'
type='whence -v'

Options

-t

Create a tracked alias for a UNIX command name. The Korn shell remembers the full pathname of the command, allowing it to be found more quickly and to be issued from any directory. If no name is supplied, current tracked aliases are listed. Tracked aliases are the same as hashed commands in the Bourne shell.

-x

Export the alias; it can now be used in shell scripts and other subshells. If no name is supplied, current exported aliases are listed.

Example

alias dir='basename `pwd`'

Previous: Reference: name | UNIX in a Nutshell: System V Edition | Next: Reference: autoload
Reference: name | Book Index | Reference: autoload


Reference: autoload

Previous: Reference: alias Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: bg

autoload

autoload [functions]

Load (define) the functions only when they are first used. Korn shell alias for typeset -fu.

Previous: Reference: alias | UNIX in a Nutshell: System V Edition | Next: Reference: bg
Reference: alias | Book Index | Reference: bg


Reference: bg

Previous: Reference: autoload Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: break

bg

bg [jobIDs]

Put current job or jobIDs in the background. See "Job Control."

Previous: Reference: autoload | UNIX in a Nutshell: System V Edition | Next: Reference: break
Reference: autoload | Book Index | Reference: break


Reference: break

Previous: Reference: bg Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: case

break

break [n]

Exit from the innermost (most deeply nested) for, while or until loop, or from the n innermost levels of the loop. Also exits from a select list.

Previous: Reference: bg | UNIX in a Nutshell: System V Edition | Next: Reference: case
Reference: bg | Book Index | Reference: case


Reference: case

Previous: Reference: break Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: cd

case

case value in
    pattern1) cmds1;;
    pattern2) cmds2;;
    .
    .
    .
esac

Execute the first set of commands (cmds1) if value matches pattern1, execute the second set of commands (cmds2) if value matches pattern2, etc. Be sure the last command in each set ends with ;; . value is typically a positional parameter or other shell variable. cmds are typically UNIX commands, shell programming commands, or variable assignments. Patterns can use file generation metacharacters. Multiple patterns (separated by |) can be specified on the same line; in this case, the associated cmds are executed whenever value matches any of these patterns. See below and under eval for examples. (Note: the Korn shell allows pattern to be preceded by an optional open parenthesis, as in (pattern). It's useful for balancing parentheses inside a $( ) construct.)

Examples

Read first command-line argument and take appropriate action:

case $1 in	#match the first arg
    no|yes) response=1;;
    -[tT])  table=TRUE;;
    *)      echo "unknown option"; exit 1;;
esac

Read user-supplied lines until user exits:

while :	# Null command; always true
do
   echo "Type . to finish ==> \c"
   read line
   case "$line" in
      .) echo "Message done"
         break ;;
      *) echo "$line" >> $message ;;
   esac
done

Previous: Reference: break | UNIX in a Nutshell: System V Edition | Next: Reference: cd
Reference: break | Book Index | Reference: cd


Reference: cd

Previous: Reference: case Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: continue

cd

cd [dir]
cd [ - ]
cd [ old new ]

With no arguments, change to home directory of user. Otherwise, change working directory to dir. If dir is a relative pathname but is not in the current directory, then the CDPATH variable is searched. The last two command forms are specific to the Korn shell, where - stands for the previous directory. The third syntax modifies the current directory name by replacing string old with new, then switches to the resulting directory.

Example

$ pwd
/usr/spool/cron
$ cd cron uucp	# cd prints the new directory
/usr/spool/uucp

Previous: Reference: case | UNIX in a Nutshell: System V Edition | Next: Reference: continue
Reference: case | Book Index | Reference: continue


Reference: continue

Previous: Reference: cd Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: do

continue

continue [n]

Skip remaining commands in a for, while, or until loop, resuming with the next iteration of the loop (or skipping n loops).

Previous: Reference: cd | UNIX in a Nutshell: System V Edition | Next: Reference: do
Reference: cd | Book Index | Reference: do


Reference: unalias

Previous: Reference: umask Chapter 4
The Bourne Shell and Korn Shell 		Next: Reference: unset

unalias

unalias names

Korn shell only. Remove names from the alias list. See also alias.

Previous: Reference: umask | UNIX in a Nutshell: System V Edition | Next: Reference: unset
Reference: umask | Book Index | Reference: unset


Reference: #

Previous: 5.6 Built-in C Shell Commands Chapter 5
The C Shell 		Next: Reference: #!

#

#

Ignore all text that follows on the same line. # is used in shell scripts as the comment character and is not really a command. In addition, a script that uses # as its first character is interpreted as a C shell script.

Previous: 5.6 Built-in C Shell Commands | UNIX in a Nutshell: System V Edition | Next: Reference: #!
5.6 Built-in C Shell Commands | Book Index | Reference: #!


Reference: #!

Previous: Reference: # Chapter 5
The C Shell 		Next: Reference: :

#!

#!shell

Used as the first line of a script to invoke the named shell (with optional arguments). Not supported in all shells. For example:

#!/bin/csh -f

Previous: Reference: # | UNIX in a Nutshell: System V Edition | Next: Reference: :
Reference: # | Book Index | Reference: :


Reference: :

Previous: Reference: #! Chapter 5
The C Shell 		Next: Reference: alias

:

:

Null command. Returns an exit status of 0.

Previous: Reference: #! | UNIX in a Nutshell: System V Edition | Next: Reference: alias
Reference: #! | Book Index | Reference: alias


Reference: alias

Previous: Reference: : Chapter 5
The C Shell 		Next: Reference: bg

alias

alias [name [command]]

Assign name as the shorthand name, or alias, for command. If command is omitted, print the alias for name; if name is also omitted, print all aliases. Aliases can be defined on the command line, but they are more often stored in .cshrc so that they take effect upon logging in. (See the sample .cshrc file earlier in this section.) Alias definitions can reference command-line arguments, much like the history list. Use \!* to refer to all command-line arguments, \!^ for the first argument, \!$ for the last, etc. An alias name can be any valid UNIX command; however, you lose the original command's meaning unless you type \name. See also unalias.

Examples

Set the size for xterm windows under the X Window System:

alias R 'set noglob; eval `resize`; unset noglob'

Show aliases that contain the string ls:

alias | grep ls

Run nroff on all command-line arguments:

alias ms 'nroff -ms \!*'

Copy the file that is named as the first argument:

alias back 'cp \!^ \!^.old'

Use the regular ls, not its alias:

% \ls

Previous: Reference: : | UNIX in a Nutshell: System V Edition | Next: Reference: bg
Reference: : | Book Index | Reference: bg


Reference: bg

Previous: Reference: alias Chapter 5
The C Shell 		Next: Reference: break

bg

bg [jobIDs]

Put the current job or the jobIDs in the background. See also "Job Control" at the end of this section.

Example

To place a time-consuming process in the background, you might begin with:

4% nroff -ms report
CTRL-Z

and then issue any one of the following:

5% bg
5% bg %	Current job
5% bg %1	Job number 1
5% bg %nr	Match initial string nroff
5% % &

Previous: Reference: alias | UNIX in a Nutshell: System V Edition | Next: Reference: break
Reference: alias | Book Index | Reference: break


Reference: break

Previous: Reference: bg Chapter 5
The C Shell 		Next: Reference: breaksw

break

break

Resume execution following the end command of the nearest enclosing while or foreach.

Previous: Reference: bg | UNIX in a Nutshell: System V Edition | Next: Reference: breaksw
Reference: bg | Book Index | Reference: breaksw


Reference: breaksw

Previous: Reference: break Chapter 5
The C Shell 		Next: Reference: case

breaksw

breaksw

Break from a switch; continue execution after the endsw.

Previous: Reference: break | UNIX in a Nutshell: System V Edition | Next: Reference: case
Reference: break | Book Index | Reference: case


Reference: case

Previous: Reference: breaksw Chapter 5
The C Shell 		Next: Reference: cd

case

case pattern :

Identify a pattern in a switch.

Previous: Reference: breaksw | UNIX in a Nutshell: System V Edition | Next: Reference: cd
Reference: breaksw | Book Index | Reference: cd


Reference: cd

Previous: Reference: case Chapter 5
The C Shell 		Next: Reference: chdir

cd

cd [dir]

Change working directory to dir; default is home directory of user. If dir is a relative pathname but is not in the current directory, the cdpath variable is searched. See the sample .cshrc file earlier in this section.

Previous: Reference: case | UNIX in a Nutshell: System V Edition | Next: Reference: chdir
Reference: case | Book Index | Reference: chdir


Reference: chdir

Previous: Reference: cd Chapter 5
The C Shell 		Next: Reference: continue

chdir

chdir [dir]

Same as cd. Useful if you are redefining cd.

Previous: Reference: cd | UNIX in a Nutshell: System V Edition | Next: Reference: continue
Reference: cd | Book Index | Reference: continue


Reference: continue

Previous: Reference: chdir Chapter 5
The C Shell 		Next: Reference: default

continue

continue

Resume execution of nearest enclosing while or foreach.

Previous: Reference: chdir | UNIX in a Nutshell: System V Edition | Next: Reference: default
Reference: chdir | Book Index | Reference: default


Reference: unsetenv

Previous: Reference: unset Chapter 5
The C Shell 		Next: Reference: wait

unsetenv

unsetenv variable

Remove an environment variable. Filename matching is not valid. See setenv.

Previous: Reference: unset | UNIX in a Nutshell: System V Edition | Next: Reference: wait
Reference: unset | Book Index | Reference: wait


Reference: wait

Previous: Reference: unsetenv Chapter 5
The C Shell 		Next: Reference: while

wait

wait

Pause in execution until all background jobs complete, or until an interrupt signal is received.

Previous: Reference: unsetenv | UNIX in a Nutshell: System V Edition | Next: Reference: while
Reference: unsetenv | Book Index | Reference: while


Reference: while

Previous: Reference: wait Chapter 5
The C Shell 		Next: Reference: @

while

while (expression)
     commands
end

As long as expression is true (evaluates to non-zero), evaluate commands between while and end. break and continue can be used to terminate or continue the loop. See also example under shift.

Example

set user = (alice bob carol ted)
while ($argv[1] != $user[1])
   #Cycle through each user, checking for a match
   shift user
   #If we cycled through with no match...
   if ($#user == 0) then
     echo "$argv[1] is not on the list of users"
     exit 1
   endif
end

Previous: Reference: wait | UNIX in a Nutshell: System V Edition | Next: Reference: @
Reference: wait | Book Index | Reference: @


Reference: @

Previous: Reference: while Chapter 5
The C Shell 		Next: 5.6 Built-in C Shell Commands

@

@ variable = expression
@ variable[n]  = expression
@

Assign the value of the arithmetic expression to variable, or to the nth element of variable if the index n is specified. With no variable or expression specified, print the values of all shell variables (same as set). Expression operators as well as examples are listed under "Expressions," earlier in this section. Two special forms are also valid:

@ variable++ Increment variable by one.

@ variable- - Decrement variable by one.

Previous: Reference: while | UNIX in a Nutshell: System V Edition | Next: 5.6 Built-in C Shell Commands
Reference: while | Book Index | 5.6 Built-in C Shell Commands


Reference: abbrev

Previous: 9.2 Alphabetical Summary of Ex Commands Chapter 9
The Ex Editor 		Next: Reference: append

abbrev

ab [string text]

Define string when typed to be translated into text. If string and text are not specified, list all current abbreviations.

Examples

Note: ^M appears when you type ^V followed by RETURN.

:ab ora O'Reilly & Associates, Inc.
:ab id Name:^MRank:^MPhone:

Previous: 9.2 Alphabetical Summary of Ex Commands | UNIX in a Nutshell: System V Edition | Next: Reference: append
9.2 Alphabetical Summary of Ex Commands | Book Index | Reference: append


Reference: append

Previous: Reference: abbrev Chapter 9
The Ex Editor 		Next: Reference: args

append

[address] a[!]
text
.

Append text at specified address, or at present address if none is specified. Add a ! to switch the autoindent setting that will be used during input. E.g., if autoindent was enabled, ! disables it.

Previous: Reference: abbrev | UNIX in a Nutshell: System V Edition | Next: Reference: args
Reference: abbrev | Book Index | Reference: args


Reference: args

Previous: Reference: append Chapter 9
The Ex Editor 		Next: Reference: change

args

ar

Print filename arguments (the list of files to edit). The current argument is shown in brackets ([]).

Previous: Reference: append | UNIX in a Nutshell: System V Edition | Next: Reference: change
Reference: append | Book Index | Reference: change


Reference: change

Previous: Reference: args Chapter 9
The Ex Editor 		Next: Reference: copy

change

[address] c[!]
text
.

Replace the specified lines with text. Add a ! to switch the autoindent setting during input of text.

Previous: Reference: args | UNIX in a Nutshell: System V Edition | Next: Reference: copy
Reference: args | Book Index | Reference: copy


Reference: copy

Previous: Reference: change Chapter 9
The Ex Editor 		Next: Reference: delete

copy

[address] co destination

Copy the lines included in address to the specified destination address. The command t is a synonym for copy.

Example

:1,10 co 50

Previous: Reference: change | UNIX in a Nutshell: System V Edition | Next: Reference: delete
Reference: change | Book Index | Reference: delete


Reference: delete

Previous: Reference: copy Chapter 9
The Ex Editor 		Next: Reference: edit

delete

[address] d [buffer]

Delete the lines included in address. If buffer is specified, save or append the text to the named buffer.

Examples

:/Part I/,/Part II/-1d	Delete to line above "Part II"
:/main/+d	Delete line below "main"
:.,$/d	Delete from this line to last line

Previous: Reference: copy | UNIX in a Nutshell: System V Edition | Next: Reference: edit
Reference: copy | Book Index | Reference: edit


Reference: edit

Previous: Reference: delete Chapter 9
The Ex Editor 		Next: Reference: file

edit

e[!] [+n] [file]

Begin editing file. Add a ! to discard any changes to the current file. If no file is given, edit another copy of the current file. With the +n argument, begin editing on line n.

Examples

:e file
:e#
:e!

Previous: Reference: delete | UNIX in a Nutshell: System V Edition | Next: Reference: file
Reference: delete | Book Index | Reference: file


Reference: file

Previous: Reference: edit Chapter 9
The Ex Editor 		Next: Reference: global

file

f [filename]

Change the name of the current file to filename, which is considered "not edited." If no filename is specified, print the current status of the file.

Example

:f %.new

Previous: Reference: edit | UNIX in a Nutshell: System V Edition | Next: Reference: global
Reference: edit | Book Index | Reference: global


Reference: global

Previous: Reference: file Chapter 9
The Ex Editor 		Next: Reference: insert

global

[address] g[!]/pattern/[commands]

Execute commands on all lines that contain pattern or, if address is specified, on all lines within that range. If commands are not specified, print all such lines. If ! is used, execute commands on all lines that don't contain pattern. See v.

Examples

:g/Unix/p
:g/Name:/s/tom/Tom/

Previous: Reference: file | UNIX in a Nutshell: System V Edition | Next: Reference: insert
Reference: file | Book Index | Reference: insert


Reference: insert

Previous: Reference: global Chapter 9
The Ex Editor 		Next: Reference: join

insert

[address] i[!]
text
.

Insert text at line before the specified address, or at present address if none is specified. Add a ! to switch the autoindent setting during input of text.

Previous: Reference: global | UNIX in a Nutshell: System V Edition | Next: Reference: join
Reference: global | Book Index | Reference: join


Reference: join

Previous: Reference: insert Chapter 9
The Ex Editor 		Next: Reference: k

join

[address] j[!] [count]

Place the text in the specified range on one line, with white space adjusted to provide two blank characters after a period (.), no blank characters after a ), and one blank character otherwise. Add a ! to prevent white space adjustment.

Example

:1,5j!	Join first five lines, preserving white space

Previous: Reference: insert | UNIX in a Nutshell: System V Edition | Next: Reference: k
Reference: insert | Book Index | Reference: k


Reference: k

Previous: Reference: join Chapter 9
The Ex Editor 		Next: Reference: list

k

[address] k char

Mark the given address with char. Return later to the line with 'x.

Previous: Reference: join | UNIX in a Nutshell: System V Edition | Next: Reference: list
Reference: join | Book Index | Reference: list


Reference: list

Previous: Reference: k Chapter 9
The Ex Editor 		Next: Reference: map

list

[address] l [count]

Print the specified lines so that tabs display as ^I and the ends of lines display as $. l is a temporary version of :set list.

Previous: Reference: k | UNIX in a Nutshell: System V Edition | Next: Reference: map
Reference: k | Book Index | Reference: map


Reference: map

Previous: Reference: list Chapter 9
The Ex Editor 		Next: Reference: mark

map

map[!] [char commands]

Define a keyboard macro named char as the specified sequence of commands. char is usually a single character, or the sequence #n, representing a function key on the keyboard. Use a ! to create a macro for input mode. With no arguments, list the currently defined macros.

Examples

:map K dwwP	Transpose two words
:map q :w^M:n^M	Write current file; go to next
:map! + ^[bi(^[ea)	Enclose previous word in parentheses

Previous: Reference: list | UNIX in a Nutshell: System V Edition | Next: Reference: mark
Reference: list | Book Index | Reference: mark


Reference: mark

Previous: Reference: map Chapter 9
The Ex Editor 		Next: Reference: move

mark

[address] ma char

Mark the specified line with char, a single lowercase letter. Return later to the line with 'x. Same as k.

Previous: Reference: map | UNIX in a Nutshell: System V Edition | Next: Reference: move
Reference: map | Book Index | Reference: move


Reference: move

Previous: Reference: mark Chapter 9
The Ex Editor 		Next: Reference: next

move

[address] m destination

Move the lines specified by address to the destination address.

Example

:.,/Note/m /END/	Move text block after line containing "END"

Previous: Reference: mark | UNIX in a Nutshell: System V Edition | Next: Reference: next
Reference: mark | Book Index | Reference: next


Reference: next

Previous: Reference: move Chapter 9
The Ex Editor 		Next: Reference: number

next

n[!] [[+command] filelist]

Edit the next file from the command-line argument list. Use args to list these files. If filelist is provided, replace the current argument list with filelist and begin editing on the first file; if command is given (containing no spaces), execute command after editing the first such file.

Example

:n chap*	Start editing all "chapter" files

Previous: Reference: move | UNIX in a Nutshell: System V Edition | Next: Reference: number
Reference: move | Book Index | Reference: number


Reference: number

Previous: Reference: next Chapter 9
The Ex Editor 		Next: Reference: open

number

[address] nu [count]

Print each line specified by address, preceded by its buffer line number. Use # as an alternate abbreviation for number. count specifies the number of lines to show, starting with address.

Previous: Reference: next | UNIX in a Nutshell: System V Edition | Next: Reference: open
Reference: next | Book Index | Reference: open


Reference: open

Previous: Reference: number Chapter 9
The Ex Editor 		Next: Reference: preserve

open

[address] o [/pattern/]

Enter vi's open mode at the lines specified by address, or at the lines matching pattern. Enter and exit open mode with Q. Open mode lets you use the regular vi commands, but only one line at a time. May be useful on slow dialup lines.

Previous: Reference: number | UNIX in a Nutshell: System V Edition | Next: Reference: preserve
Reference: number | Book Index | Reference: preserve


Reference: preserve

Previous: Reference: open Chapter 9
The Ex Editor 		Next: Reference: print

preserve

pre

Save the current editor buffer as though the system had crashed.

Previous: Reference: open | UNIX in a Nutshell: System V Edition | Next: Reference: print
Reference: open | Book Index | Reference: print


Reference: print

Previous: Reference: preserve Chapter 9
The Ex Editor 		Next: Reference: put

print

[address] p [count]

Print the lines specified by address. count specifies the number of lines to print, starting with address. P is another abbreviation.

Example

:100;+5p	Show line 100 and the next five lines

Previous: Reference: preserve | UNIX in a Nutshell: System V Edition | Next: Reference: put
Reference: preserve | Book Index | Reference: put


Reference: put

Previous: Reference: print Chapter 9
The Ex Editor 		Next: Reference: quit

put

[address] pu [char]

Restore the lines that were previously deleted or yanked from named buffer char, and put them after the line specified by address. If char is not specified, restore the last deleted or yanked text.

Previous: Reference: print | UNIX in a Nutshell: System V Edition | Next: Reference: quit
Reference: print | Book Index | Reference: quit


Reference: quit

Previous: Reference: put Chapter 9
The Ex Editor 		Next: Reference: read

quit

q[!]

Terminate current editing session. Use ! to discard changes made since the last save. If the editing session includes additional files in the argument list that were never accessed, quit by typing q! or by typing q twice.

Previous: Reference: put | UNIX in a Nutshell: System V Edition | Next: Reference: read
Reference: put | Book Index | Reference: read


Reference: read

Previous: Reference: quit Chapter 9
The Ex Editor 		Next: Reference: read

read

[address] r file

Copy in the text from file on the line below the specified address. If file is not specified, the current filename is used.

Example

:0r $HOME/data	Read file in at top of current file

Previous: Reference: quit | UNIX in a Nutshell: System V Edition | Next: Reference: read
Reference: quit | Book Index | Reference: read


Reference: read

Previous: Reference: read Chapter 9
The Ex Editor 		Next: Reference: recover

read

[address] r !command

Read the output of UNIX command into the text after the line specified by address.

Example

:$r !cal	Place a calendar at end of file

Previous: Reference: read | UNIX in a Nutshell: System V Edition | Next: Reference: recover
Reference: read | Book Index | Reference: recover


Reference: recover

Previous: Reference: read Chapter 9
The Ex Editor 		Next: Reference: rewind

recover

rec [file]

Recover file from system save area.

Previous: Reference: read | UNIX in a Nutshell: System V Edition | Next: Reference: rewind
Reference: read | Book Index | Reference: rewind


Reference: rewind

Previous: Reference: recover Chapter 9
The Ex Editor 		Next: Reference: set

rewind

rew[!]

Rewind argument list and begin editing the first file in the list. The ! flag rewinds, discarding any changes to the current file that haven't been saved.

Previous: Reference: recover | UNIX in a Nutshell: System V Edition | Next: Reference: set
Reference: recover | Book Index | Reference: set


Reference: set

Previous: Reference: rewind Chapter 9
The Ex Editor 		Next: Reference: shell

set

se parameter1 parameter2 ...

Set a value to an option with each parameter, or if no parameter is supplied, print all options that have been changed from their defaults. For Boolean-valued options, each parameter can be phrased as option or no option; other options can be assigned with the syntax option=value. Specify all to list current settings.

Examples

:set nows wm=10
:set all

Previous: Reference: rewind | UNIX in a Nutshell: System V Edition | Next: Reference: shell
Reference: rewind | Book Index | Reference: shell


Reference: shell

Previous: Reference: set Chapter 9
The Ex Editor 		Next: Reference: source

shell

sh

Create a new shell. Resume editing when the shell is terminated.

Previous: Reference: set | UNIX in a Nutshell: System V Edition | Next: Reference: source
Reference: set | Book Index | Reference: source


Reference: source

Previous: Reference: shell Chapter 9
The Ex Editor 		Next: Reference: substitute

source

so file

Read and execute ex commands from file.

Examples

:so $HOME/.exrc

Previous: Reference: shell | UNIX in a Nutshell: System V Edition | Next: Reference: substitute
Reference: shell | Book Index | Reference: substitute


Reference: substitute

Previous: Reference: source Chapter 9
The Ex Editor 		Next: Reference: t

substitute

[address] s [/pattern/replacement/] [options] [count]

Replace each instance of pattern on the specified lines with replacement. If pattern and replacement are omitted, repeat last substitution. count specifies the number of lines on which to substitute, starting with address. See additional examples in Section 6.

Options

c

Prompt for confirmation before each change.

g

Substitute all instances of pattern on each line.

p

Print the last line on which a substitution was made.

Examples

:1,10s/yes/no/g	Substitute on first 10 lines
:%s/[Hh]ello/Hi/gc	Confirm global substitutions
:s/Fortran/\U&/ 3	Uppercase "Fortran" on next three lines

Previous: Reference: source | UNIX in a Nutshell: System V Edition | Next: Reference: t
Reference: source | Book Index | Reference: t


Reference: t

Previous: Reference: substitute Chapter 9
The Ex Editor 		Next: Reference: tag

t

[address] t destination

Copy the lines included in address to the specified destination address. t is an alias for copy.

Example

:%t$	Copy the file and add it to the end

Previous: Reference: substitute | UNIX in a Nutshell: System V Edition | Next: Reference: tag
Reference: substitute | Book Index | Reference: tag


Reference: tag

Previous: Reference: t Chapter 9
The Ex Editor 		Next: Reference: unabbreviate

tag

[address] ta tag

Switch the editing session to the file containing tag.

Example

Run ctags, then switch to the file containing myfunction:

:!ctags *.c
:tag myfunction

Previous: Reference: t | UNIX in a Nutshell: System V Edition | Next: Reference: unabbreviate
Reference: t | Book Index | Reference: unabbreviate


Reference: unabbreviate

Previous: Reference: tag Chapter 9
The Ex Editor 		Next: Reference: undo

unabbreviate

una word

Remove word from the list of abbreviations.

Previous: Reference: tag | UNIX in a Nutshell: System V Edition | Next: Reference: undo
Reference: tag | Book Index | Reference: undo


Reference: undo

Previous: Reference: unabbreviate Chapter 9
The Ex Editor 		Next: Reference: unmap

undo

u

Reverse the changes made by the last editing command.

Previous: Reference: unabbreviate | UNIX in a Nutshell: System V Edition | Next: Reference: unmap
Reference: unabbreviate | Book Index | Reference: unmap


Reference: unmap

Previous: Reference: undo Chapter 9
The Ex Editor 		Next: Reference: v

unmap

unm[!] char

Remove char from the list of keyboard macros. Use ! to remove a macro for input mode.

Previous: Reference: undo | UNIX in a Nutshell: System V Edition | Next: Reference: v
Reference: undo | Book Index | Reference: v


Reference: v

Previous: Reference: unmap Chapter 9
The Ex Editor 		Next: Reference: version

v

[address] v/pattern/[commands]

Execute commands on all lines not containing pattern. If commands are not specified, print all such lines. v is equivalent to g!.

Example

:v/#include/d	Delete all lines except "#include" lines

Previous: Reference: unmap | UNIX in a Nutshell: System V Edition | Next: Reference: version
Reference: unmap | Book Index | Reference: version


Reference: version

Previous: Reference: v Chapter 9
The Ex Editor 		Next: Reference: visual

version

ve

Print the editor's current version number and date of last change.

Previous: Reference: v | UNIX in a Nutshell: System V Edition | Next: Reference: visual
Reference: v | Book Index | Reference: visual


Reference: visual

Previous: Reference: version Chapter 9
The Ex Editor 		Next: Reference: visual

visual

[address] vi [type] [count]

Enter visual mode (vi) at the line specified by address. Exit with Q. type can be one of -, ^, or . (See the z command). count specifies an initial window size.

Previous: Reference: version | UNIX in a Nutshell: System V Edition | Next: Reference: visual
Reference: version | Book Index | Reference: visual


Reference: visual

Previous: Reference: visual Chapter 9
The Ex Editor 		Next: Reference: write

visual

vi [+n] file

Begin editing file in visual mode (vi), optionally at line n.

Previous: Reference: visual | UNIX in a Nutshell: System V Edition | Next: Reference: write
Reference: visual | Book Index | Reference: write


Reference: write

Previous: Reference: visual Chapter 9
The Ex Editor 		Next: Reference: write

write

[address] w[!] [[>>] file]

Write lines specified by address to file, or write full contents of buffer if address is not specified. If file is also omitted, save the contents of the buffer to the current filename. If >> file is used, write contents to the end of an existing file. The ! flag forces the editor to write over any current contents of file.

Previous: Reference: visual | UNIX in a Nutshell: System V Edition | Next: Reference: write
Reference: visual | Book Index | Reference: write


Reference: write

Previous: Reference: write Chapter 9
The Ex Editor 		Next: Reference: wq

write

[address] w !command

Write lines specified by address to command.

Examples

:1,10w name_list	Copy first 10 lines to name_list
:50w >> name_list	Now append line 50

Previous: Reference: write | UNIX in a Nutshell: System V Edition | Next: Reference: wq
Reference: write | Book Index | Reference: wq


Reference: wq

Previous: Reference: write Chapter 9
The Ex Editor 		Next: Reference: xit

wq

wq[!]

Write and quit the file in one movement. The ! flag forces the editor to write over any current contents of file.

Previous: Reference: write | UNIX in a Nutshell: System V Edition | Next: Reference: xit
Reference: write | Book Index | Reference: xit


Reference: xit

Previous: Reference: wq Chapter 9
The Ex Editor 		Next: Reference: yank

xit

x

Write the file if it was changed since the last write; then quit.

Previous: Reference: wq | UNIX in a Nutshell: System V Edition | Next: Reference: yank
Reference: wq | Book Index | Reference: yank


Reference: yank

Previous: Reference: xit Chapter 9
The Ex Editor 		Next: Reference: z

yank

[address] ya [char] [count]

Place lines specified by address in named buffer char. If no char is given, place lines in general buffer. count specifies the number of lines to yank, starting with address.

Example

:101,200 ya a

Previous: Reference: xit | UNIX in a Nutshell: System V Edition | Next: Reference: z
Reference: xit | Book Index | Reference: z


Reference: z

Previous: Reference: yank Chapter 9
The Ex Editor 		Next: Reference: !

z

[address] z [type] [count]

Print a window of text, with the line specified by address at the top. count specifies the number of lines to be displayed.

Type

+

Place specified line at top of window (the default).

-

Place specified line at bottom of window.

.

Place specified line in center of window.

^

Print the previous window.

=

Place specified line in center of window, and leave this line as the current line.

Previous: Reference: yank | UNIX in a Nutshell: System V Edition | Next: Reference: !
Reference: yank | Book Index | Reference: !


Reference: !

Previous: Reference: z Chapter 9
The Ex Editor 		Next: Reference: =

!

[address] !command

Execute UNIX command in a shell. If address is specified, apply the lines contained in address as standard input to command, and replace the lines with the output.

Examples

:!ls	List files in the current directory
:11,20!sort -f	Sort lines 11-20 of current file

Previous: Reference: z | UNIX in a Nutshell: System V Edition | Next: Reference: =
Reference: z | Book Index | Reference: =


Reference: =

Previous: Reference: ! Chapter 9
The Ex Editor 		Next: Reference: < >

=

[address] =

Print the line number of the next line matching address. If no address is given, print the number of the last line.

Previous: Reference: ! | UNIX in a Nutshell: System V Edition | Next: Reference: < >
Reference: ! | Book Index | Reference: < >


Reference: < >

Previous: Reference: = Chapter 9
The Ex Editor 		Next: Reference: address

< >

[address] < [count]
     or
[address] > [count]

Shift lines specified by address either left (<) or right (>). Only blanks and tabs are shifted in a left shift. count specifies the number of lines to shift, starting with address.

Previous: Reference: = | UNIX in a Nutshell: System V Edition | Next: Reference: address
Reference: = | Book Index | Reference: address


Reference: address

Previous: Reference: < > Chapter 9
The Ex Editor 		Next: Reference: RETURN

address

address

Print the line specified in address.

Previous: Reference: < > | UNIX in a Nutshell: System V Edition | Next: Reference: RETURN
Reference: < > | Book Index | Reference: RETURN


Reference: RETURN

Previous: Reference: address Chapter 9
The Ex Editor 		Next: Reference: &

RETURN

RETURN

Print the next line in the file.

Previous: Reference: address | UNIX in a Nutshell: System V Edition | Next: Reference: &
Reference: address | Book Index | Reference: &


Reference: &

Previous: Reference: RETURN Chapter 9
The Ex Editor 		Next: Reference: ~

&

[address] & [options] [count]

Repeat the previous substitution (s) command. count specifies the number of lines on which to substitute, starting with address.

Examples

:s/Overdue/Paid/	Substitute once on current line
:g/Status/&	Redo substitution on all "Status" lines

Previous: Reference: RETURN | UNIX in a Nutshell: System V Edition | Next: Reference: ~
Reference: RETURN | Book Index | Reference: ~


Reference: ~

Previous: Reference: & Chapter 9
The Ex Editor 		Next: 9. The Ex Editor

~

[address] ~ [count]

Replace the previous regular expression with the previous replacement pattern from a substitute (s) command.

Previous: Reference: & | UNIX in a Nutshell: System V Edition | Next: 9. The Ex Editor
Reference: & | Book Index | 9. The Ex Editor


Reference: #

Previous: 10.5 Alphabetical Summary of Sed Commands Chapter 10
The Sed Editor 		Next: Reference: :

#

#

Begin a comment in a sed script. Valid only as the first character of the first line.

Previous: 10.5 Alphabetical Summary of Sed Commands | UNIX in a Nutshell: System V Edition | Next: Reference: :
10.5 Alphabetical Summary of Sed Commands | Book Index | Reference: :


Reference: :

Previous: Reference: # Chapter 10
The Sed Editor 		Next: Reference: =

:

:label

Label a line in the script for the transfer of control by b or t. label may contain up to seven characters.

Previous: Reference: # | UNIX in a Nutshell: System V Edition | Next: Reference: =
Reference: # | Book Index | Reference: =


Reference: =

Previous: Reference: : Chapter 10
The Sed Editor 		Next: Reference: a

=

[/pattern/]=

Write to standard output the line number of each line addressed by pattern.

Previous: Reference: : | UNIX in a Nutshell: System V Edition | Next: Reference: a
Reference: : | Book Index | Reference: a


Reference: a

Previous: Reference: = Chapter 10
The Sed Editor 		Next: Reference: b

a

[address]a\
text

Append text following each line matched by address. If text goes over more than one line, newlines must be "hidden" by preceding them with a backslash. The text will be terminated by the first newline that is not hidden in this way. The text is not available in the pattern space, and subsequent commands cannot be applied to it. The results of this command are sent to standard output when the list of editing commands is finished, regardless of what happens to the current line in the pattern space.

Example

$a\
This goes after the last line in the file\
(marked by $).  This text is escaped at the\
end of each line, except for the last one.

Previous: Reference: = | UNIX in a Nutshell: System V Edition | Next: Reference: b
Reference: = | Book Index | Reference: b


Reference: b

Previous: Reference: a Chapter 10
The Sed Editor 		Next: Reference: c

b

[address1][,address2]b[label]

Transfer control unconditionally to :label elsewhere in script. That is, the command following the label is the next command applied to the current line. If no label is specified, control falls through to the end of the script, so no more commands are applied to the current line.

Example

# Ignore tbl tables; resume script after TE:
/^\.TS/,/^\.TE/b

Previous: Reference: a | UNIX in a Nutshell: System V Edition | Next: Reference: c
Reference: a | Book Index | Reference: c


Reference: c

Previous: Reference: b Chapter 10
The Sed Editor 		Next: Reference: d

c

[address1][,address2]c\
text

Replace the lines selected by the address with text. When a range of lines is specified, all lines as a group are replaced by a single copy of text. The newline following each line of text must be escaped by a backslash, except the last line. The contents of the pattern space are, in effect, deleted and no subsequent editing commands can be applied to it (or text).

Example

# Replace first 100 lines in a file:
1,100c\
\
<First 100 names to be supplied>

Previous: Reference: b | UNIX in a Nutshell: System V Edition | Next: Reference: d
Reference: b | Book Index | Reference: d


Reference: atan2

Previous: 11.8 Alphabetical Summary of Commands Chapter 11
The Awk Scripting Language 		Next: Reference: break

atan2

atan2(y,x)

Return the arctangent of y/x in radians. {N}

Previous: 11.8 Alphabetical Summary of Commands | UNIX in a Nutshell: System V Edition | Next: Reference: break
11.8 Alphabetical Summary of Commands | Book Index | Reference: break


Reference: break

Previous: Reference: atan2 Chapter 11
The Awk Scripting Language 		Next: Reference: close

break

break

Exit from a while or for loop.

Previous: Reference: atan2 | UNIX in a Nutshell: System V Edition | Next: Reference: close
Reference: atan2 | Book Index | Reference: close


Reference: close

Previous: Reference: break Chapter 11
The Awk Scripting Language 		Next: Reference: continue

close

close(filename-expr)
close(command-expr)

In most implementations of awk, you can only have ten files open simultaneously and one pipe. Therefore, nawk provides a close statement that allows you to close a file or a pipe. It takes as an argument the same expression that opened the pipe or file. {N}

Previous: Reference: break | UNIX in a Nutshell: System V Edition | Next: Reference: continue
Reference: break | Book Index | Reference: continue


Reference: continue

Previous: Reference: close Chapter 11
The Awk Scripting Language 		Next: Reference: cos

continue

continue

Begin next iteration of while or for loop without reaching the bottom.

Previous: Reference: close | UNIX in a Nutshell: System V Edition | Next: Reference: cos
Reference: close | Book Index | Reference: cos


Reference: cos

Previous: Reference: continue Chapter 11
The Awk Scripting Language 		Next: Reference: delete

cos

cos(x)

Return the cosine of x, an angle in radians.

Previous: Reference: continue | UNIX in a Nutshell: System V Edition | Next: Reference: delete
Reference: continue | Book Index | Reference: delete


Reference: admin

Previous: 17.5 Alphabetical Summary of SCCS Commands Chapter 17
The SCCS Utility 		Next: Reference: cdc

admin

admin [options] files

Add files to SCCS or change options of SCCS files.

Options

-a[user|groupid]

Assign user or groupid permission to make deltas; a ! before user or groupid denies permission. If no list is given, anyone has permission.

-dflag

Delete flag previously set with -f. Applicable flags are:

b

Enable the -b option in a get command; this allows branch deltas.

c n

Set highest release to n (default is 9999).

d n

Set get default delta number to n.

f n

Set lowest release to n (default is 1).

i[string]

Treat "No id keywords (ge6)" as a fatal error. string, if present, forces a fatal error if keywords do not exactly match string. Allow multiple concurrent gets.

l list

Releases in list cannot accept changes; use the letter a to specify all releases. Substitute %M% keyword with module name. Create a null delta from which to branch. Substitute %Q% keyword with string.

t type

Substitute %Y% keyword with module type.

v[prog]

Force delta command to prompt for modification request numbers as the reason for creating a delta. Run program file prog to check for valid numbers.

-e[user|groupid]

Permission to make deltas is denied to each user or groupid.

-fflag

Set flag (see -d above).

-h

Check an existing SCCS file for possible corruption.

-i[file]

Create a new SCCS file using the contents of file as the initial delta. If file is omitted, use standard input.

-m[list]

Insert list of modification request numbers as the reason for creating the file.

-n

Create a new SCCS file that is empty.

-rn.n

Set initial delta to release number n.n. Default is 1.1. Must be used with -i.

-t[file]

Replace SCCS file description with contents of file. If file is missing, the existing description is deleted.

-y[text]

Insert text as comment for initial delta (valid only with -i or -n).

-z

Recompute the SCCS file checksum and store in first line.

Previous: 17.5 Alphabetical Summary of SCCS Commands | UNIX in a Nutshell: System V Edition | Next: Reference: cdc
17.5 Alphabetical Summary of SCCS Commands | Book Index | Reference: cdc


Reference: cdc

Previous: Reference: admin Chapter 17
The SCCS Utility 		Next: Reference: comb

cdc

cdc -rsid [options] files

Change the delta comments of the specified sid (SCCS ID) of one or more SCCS files.

Options

-m[list]

Add the list of modification request numbers (use a ! before any number to delete it). -m is useful only when admin has set the v flag for file. If -m is omitted, the terminal displays MRs? as an input prompt.

-y[string]

Add string to the comments for the specified delta. If -y is omitted, the terminal displays comments? as an input prompt.

Example

For delta 1.3 of file s.prog.c, add modification numbers x01-5 and x02-8 and then add comments:

cdc -r1.3 s.prog.c
MRs? x01-5 x02-8
comments? this went out to review

Previous: Reference: admin | UNIX in a Nutshell: System V Edition | Next: Reference: comb
Reference: admin | Book Index | Reference: comb


Reference: comb

Previous: Reference: cdc Chapter 17
The SCCS Utility 		Next: Reference: delta

comb

comb [options] files

Reduce the size of the specified SCCS files. This is done by pruning selected deltas and combining those that remain, thereby reconstructing the SCCS file. The default behavior prunes all but the most recent delta in a particular branch and keeps only those ancestors needed to preserve the tree structure. comb produces a shell script on standard output. Actual reconstruction of the SCCS files is done by running the script.

Options

-clist

Preserve only those deltas whose SCCS IDs are specified in the comma-separated list. Use a hyphen (-) to supply a range; e.g., 1.3,2.1-2.5.

-o

Access the reconstructed file at the release number of the delta that is created, instead of at the most recent ancestor. This option may change the tree structure.

-psid

In reconstructing file, discard all deltas whose SCCS identification string is older than sid.

-s

Generate a shell script that calculates how much the file has been reduced in size. -s is useful as a preview of what comb will do when actually run.

Previous: Reference: cdc | UNIX in a Nutshell: System V Edition | Next: Reference: delta
Reference: cdc | Book Index | Reference: delta


Reference: sccsdiff

Previous: Reference: sact Chapter 17
The SCCS Utility 		Next: Reference: unget

sccsdiff

sccsdiff -rsid1  -rsid2  [options] files

Report differences between two versions of an SCCS file. sid1 and sid2 identify the deltas to be compared. This command invokes bdiff (which in turn calls diff).

Options

-p

Pipe output through pr.

-sn

Use file segment size n (n is passed to bdiff).

Previous: Reference: sact | UNIX in a Nutshell: System V Edition | Next: Reference: unget
Reference: sact | Book Index | Reference: unget


Reference: ci

Previous: 18.5 Alphabetical Summary of Commands Chapter 18
The RCS Utility 		Next: Reference: co

ci

ci [options] files

Check in revisions. ci stores the contents of the specified working files into their corresponding RCS files. Normally, ci deletes the working file after storing it. If no RCS file exists, then the working file is an initial revision. In this case, the RCS file is created and you are prompted to enter a description of the file. If an RCS file exists, ci increments the revision number and prompts you to enter a message that logs the changes made. In RCS Version 5.6, if a working file is checked in without changes, the file reverts to the previous revision. In older RCS versions, you may end up having to check in a new revision that contains no changes.

The mutually exclusive options -u, -l, and -r, are the most common. Use -u to keep a read-only copy of the working file (for example, so that the file can be compiled or searched). Use -l to update a revision and then immediately check it out again with a lock. This allows you to save intermediate changes but continue editing (for example, during a long editing session). Use -r to check in a file with a different release number. ci accepts the standard options -q, -V, and -x.

Options

-d[date]

Check the file in with a timestamp of date or, if no date is specified, with the time of last modification.

-f[R]

Force a check in even if there are no differences.

-I[R]

Interactive mode; prompt user even when standard input is not a terminal (e.g., when ci is part of a command pipeline). -I is new in RCS Version 5.

-k[R]

Assign a revision number, creation date, state, and author from keyword values that were placed in the working file, instead of computing the revision information from the local environment. -k is useful for software distribution: the preset keywords serve as a timestamp shared by all distribution sites.

-l[R]

Do a co -l after checking in. This leaves a locked copy of the next revision.

-mmsg

Use the msg string as the log message for all files checked in. When checking in multiple files, ci normally prompts whether to reuse the log message of the previous file. -m bypasses this prompting.

-M[R]

Set the working file's modification time to that of the retrieved version. Use of -M can confuse make and should be used with care. (New in RCS Version 5.6.)

-nname

Associate a text name with the new revision number.

-Nname

Same as -n, but override a previous name.

-r[R]

Check the file in as revision R.

-sstate

Set the state of the checked-in revision.

-tfile

Replace RCS file description with contents of file. As of Version 5, this works only for initial check in.

-t-string

Replace RCS file description with string. As of Version 5, this works only for initial check in.

-u[R]

Do a co -u after checking in. This leaves a read-only copy.

-wuser

Set the author field to user in the checked-in revision.

Examples

Check in chapter files using the same log message:

ci -m'First round edits' chap*

Check in edits to prog.c, leaving a read-only copy:

ci -u prog.c

Start revision level 2; refer to revision 2.1 as "Prototype":

ci -r2 -nPrototype prog.c

Previous: 18.5 Alphabetical Summary of Commands | UNIX in a Nutshell: System V Edition | Next: Reference: co
18.5 Alphabetical Summary of Commands | Book Index | Reference: co


Reference: co

Previous: Reference: ci Chapter 18
The RCS Utility 		Next: Reference: ident

co

co [options] files

Retrieve a previously checked-in revision, and place it in the corresponding working file (or print to standard output if -p is specified). If you intend to edit the working file and check it in again, specify -l to lock the file. co accepts the standard options -q, -V, and -x.

Options

-ddate

Retrieve latest revision whose check-in timestamp is on or before date.

-f[R]

Force the working file to be overwritten.

-I[R]

Interactive mode; prompt user even when standard input is not a terminal. (New in RCS Version 5.)

-jR2:R3

This works like rcsmerge. R2 and R3 specify two revisions whose changes are merged into a third file: either the corresponding working file, or a third revision (any R specified by other co options).

-kc

Expand keyword symbols according to flag c. c can be:

kv

Expand symbols to keyword and value (the default). Insert the locker's name only during a ci -l or co -l.

kvl

Like kv, but always insert the locker's name.

k

Expand symbols to keywords only (no values). This is useful for ignoring trivial differences during file comparison.

o

Expand symbols to keyword and value present in previous revision. This is useful for binary files that don't allow substring changes.

v

Expand symbols to values only (no keywords). This prevents further keyword substitution and is not recommended.

-l[R]

Same as -r, but also lock the retrieved revision.

-M[R]

Set the working file's modification time to that of the retrieved version. Use of -M can confuse make and should be used with care. (New in RCS Version 5.6.)

-p[R]

Send retrieved revision to standard output instead of to a working file. Useful for output redirection or filtering.

-r[R]

Retrieve the latest revision or, if R is given, retrieve the latest revision that is equal to or lower than R.

-sstate

Retrieve the latest revision having the given state.

-u[R]

Same as -r, but also unlock the retrieved revision if you locked it previously.

-w[user]

Retrieve the latest revision that was checked in either by the invoking user or by the specified user.

Examples

Sort the latest stored version of file:

co -p file | sort

Check out (and lock) all uppercase filenames for editing:

co -l [A-Z]*

Note that filename expansion fails unless a working copy resides in the current directory. Therefore, this example works only if the files were previously checked in via ci -u. Finally, here are some different ways to extract the working files for a set of RCS files (in the current directory):

co -r3 *,v	Latest revisions of release 3
co -r3 -wjim *,v	Same, but only if checked in by jim
co -d'May 5, 2 pm LT' *,v	Latest revisions that were
    modified on or before the date
co -rPrototype *,v	Latest revisions named Prototype

Previous: Reference: ci | UNIX in a Nutshell: System V Edition | Next: Reference: ident
Reference: ci | Book Index | Reference: ident


Reference: rcsdiff

Previous: Reference: rcsclean Chapter 18
The RCS Utility 		Next: Reference: rcsfreeze

rcsdiff

rcsdiff [options] [diff_options] files

Compare revisions via diff. Specify revisions using -r as follows:

Number of Revisions specified: | Comparison made:
None | Working file against latest revision
One | Working file against specified revision
Two | One revision against the other

rcsdiff accepts the standard options -q, -V, and -x, as well as diff_options, which can be any valid diff option. rcsdiff exits with a status of 0 (no differences), 1 (some differences), or 2 (unknown problem).

Options

-kc

When comparing revisions, expand keywords using style c. (See co for values of c.)

-rR1

Use revision R1 in the comparison.

-rR2

Use revision R2 in the comparison. (-r R1 must also be specified.)

Previous: Reference: rcsclean | UNIX in a Nutshell: System V Edition | Next: Reference: rcsfreeze
Reference: rcsclean | Book Index | Reference: rcsfreeze


Reference: alias

Previous: 20.2 The Dbx Debugger Chapter 20
Program Debugging 		Next: Reference: assign

alias

alias name command
alias name(parameters)  command  string

Define name to be an alias for command. For example:

alias s(n) "stop at n"

means that the command s(20) expands to stop at 20. See also unalias.

Previous: 20.2 The Dbx Debugger | UNIX in a Nutshell: System V Edition | Next: Reference: assign
20.2 The Dbx Debugger | Book Index | Reference: assign


Reference: assign

Previous: Reference: alias Chapter 20
Program Debugging 		Next: Reference: call

assign

assign var = expr

Assign the value of expr to variable var.

Previous: Reference: alias | UNIX in a Nutshell: System V Edition | Next: Reference: call
Reference: alias | Book Index | Reference: call


Reference: call

Previous: Reference: assign Chapter 20
Program Debugging 		Next: Reference: catch

call

call func(parameters)

Execute object code associated with func.

Previous: Reference: assign | UNIX in a Nutshell: System V Edition | Next: Reference: catch
Reference: assign | Book Index | Reference: catch


Reference: catch

Previous: Reference: call Chapter 20
Program Debugging 		Next: Reference: cd

catch

catch [signals]

Start trapping signals before they are sent to the program. Specify one or more signals by number or by name. Omit signal to display the currently caught signal. See also ignore.

Previous: Reference: call | UNIX in a Nutshell: System V Edition | Next: Reference: cd
Reference: call | Book Index | Reference: cd


Reference: cd

Previous: Reference: catch Chapter 20
Program Debugging 		Next: Reference: clear

cd

cd [directory]

Change the working directory for dbx.

Previous: Reference: catch | UNIX in a Nutshell: System V Edition | Next: Reference: clear
Reference: catch | Book Index | Reference: clear


Reference: clear

Previous: Reference: cd Chapter 20
Program Debugging 		Next: Reference: cont

clear

clear [n]

Clear breakpoints at source line n or at current stopping point.

Previous: Reference: cd | UNIX in a Nutshell: System V Edition | Next: Reference: cont
Reference: cd | Book Index | Reference: cont


Reference: cont

Previous: Reference: clear Chapter 20
Program Debugging 		Next: Reference: CTRL-C

cont

cont [at n] [sig signal]

Continue execution from the point at which it was stopped. Resume from source line n or, if a signal name or number is specified, resume process as if it had received the signal.

Previous: Reference: clear | UNIX in a Nutshell: System V Edition | Next: Reference: CTRL-C
Reference: clear | Book Index | Reference: CTRL-C


Reference: CTRL-C

Previous: Reference: cont Chapter 20
Program Debugging 		Next: Reference: dbxenv

CTRL-C

CTRL-C

Interrupt program being debugged; return to dbx.

Previous: Reference: cont | UNIX in a Nutshell: System V Edition | Next: Reference: dbxenv
Reference: cont | Book Index | Reference: dbxenv


Reference: dbxenv

Previous: Reference: CTRL-C Chapter 20
Program Debugging 		Next: Reference: debug

dbxenv

dbxenv [args]

Display dbx attributes, or change attribute args. Type help for details.

Previous: Reference: CTRL-C | UNIX in a Nutshell: System V Edition | Next: Reference: debug
Reference: CTRL-C | Book Index | Reference: debug


Reference: debug

Previous: Reference: dbxenv Chapter 20
Program Debugging 		Next: Reference: delete

debug

debug [objfile [corefile]]

Restart dbx on the specified files or, with no arguments, print the current program name.

Previous: Reference: dbxenv | UNIX in a Nutshell: System V Edition | Next: Reference: delete
Reference: dbxenv | Book Index | Reference: delete


Reference: delete

Previous: Reference: debug Chapter 20
Program Debugging 		Next: Reference: detach

delete

delete n

Remove traces, stops, and whens corresponding to each command number n, given by status. If n is all, remove all.

Previous: Reference: debug | UNIX in a Nutshell: System V Edition | Next: Reference: detach
Reference: debug | Book Index | Reference: detach


Reference: detach

Previous: Reference: delete Chapter 20
Program Debugging 		Next: Reference: display

detach

detach

Separate the current program (or process) from dbx.

Previous: Reference: delete | UNIX in a Nutshell: System V Edition | Next: Reference: display
Reference: delete | Book Index | Reference: display


Reference: display

Previous: Reference: detach Chapter 20
Program Debugging 		Next: Reference: down

display

display [expressions]

Show the value of one or more expressions each time execution stops. With no arguments, list expressions currently being shown. See also undisplay.

Previous: Reference: detach | UNIX in a Nutshell: System V Edition | Next: Reference: down
Reference: detach | Book Index | Reference: down


Reference: down

Previous: Reference: display Chapter 20
Program Debugging 		Next: Reference: dump

down

down [n]

Move current function down n levels on stack. Default is 1. See also up.

Previous: Reference: display | UNIX in a Nutshell: System V Edition | Next: Reference: dump
Reference: display | Book Index | Reference: dump


Reference: dump

Previous: Reference: down Chapter 20
Program Debugging 		Next: Reference: edit

dump

dump [func] [> file]

Print names and values of variables in func (or in current procedure). Optionally store output in file. If func is ., dump all active variables.

Previous: Reference: down | UNIX in a Nutshell: System V Edition | Next: Reference: edit
Reference: down | Book Index | Reference: edit


Reference: edit

Previous: Reference: dump Chapter 20
Program Debugging 		Next: Reference: file

edit

edit [file]
edit func

Invoke editor either on file, on current source file (if no file is given), or on file containing func. The EDITOR environment variable determines which editor is used.

Previous: Reference: dump | UNIX in a Nutshell: System V Edition | Next: Reference: file
Reference: dump | Book Index | Reference: file


Reference: file

Previous: Reference: edit Chapter 20
Program Debugging 		Next: Reference: func

file

file [file]

Change name of current source file to file or, if no file is given, print name of current source file.

Previous: Reference: edit | UNIX in a Nutshell: System V Edition | Next: Reference: func
Reference: edit | Book Index | Reference: func


Reference: func

Previous: Reference: file Chapter 20
Program Debugging 		Next: Reference: help

func

func [func]

Change current function to func or, if no func is given, print current function.

Previous: Reference: file | UNIX in a Nutshell: System V Edition | Next: Reference: help
Reference: file | Book Index | Reference: help


Reference: help

Previous: Reference: func Chapter 20
Program Debugging 		Next: Reference: history

help

help [command]

Print a synopsis of all dbx commands or of the given command.

Previous: Reference: func | UNIX in a Nutshell: System V Edition | Next: Reference: history
Reference: func | Book Index | Reference: history


Reference: history

Previous: Reference: help Chapter 20
Program Debugging 		Next: Reference: ignore

history

history [n]

List the last n dbx commands issued (default is 15). Same as C shell's history command. History substitutions are supported for reissuing commands.

Previous: Reference: help | UNIX in a Nutshell: System V Edition | Next: Reference: ignore
Reference: help | Book Index | Reference: ignore


Reference: ignore

Previous: Reference: history Chapter 20
Program Debugging 		Next: Reference: kill

ignore

ignore [signals]

Stop trapping signals before they are sent to the program. Specify one or more signals by number or by name. Omit signal to display the currently ignored signal. See also catch.

Previous: Reference: history | UNIX in a Nutshell: System V Edition | Next: Reference: kill
Reference: history | Book Index | Reference: kill


Reference: kill

Previous: Reference: ignore Chapter 20
Program Debugging 		Next: Reference: language

kill

kill

Stop execution or debugging of current program.

Previous: Reference: ignore | UNIX in a Nutshell: System V Edition | Next: Reference: language
Reference: ignore | Book Index | Reference: language


Reference: language

Previous: Reference: kill Chapter 20
Program Debugging 		Next: Reference: list

language

language [name]

Set the programming language to name, which can be one of c, c++, fortran, or pascal. With no name, show the language currently in use.

Previous: Reference: kill | UNIX in a Nutshell: System V Edition | Next: Reference: list
Reference: kill | Book Index | Reference: list


Reference: list

Previous: Reference: language Chapter 20
Program Debugging 		Next: Reference: make

list

list [n1 [,n2]]
list func

List the source text between lines n1 and n2, or on lines surrounding the first statement of func. With no arguments, list the next ten lines.

Previous: Reference: language | UNIX in a Nutshell: System V Edition | Next: Reference: make
Reference: language | Book Index | Reference: make


Reference: make

Previous: Reference: list Chapter 20
Program Debugging 		Next: Reference: modules

make

make

Run make on the program being debugged.

Previous: Reference: list | UNIX in a Nutshell: System V Edition | Next: Reference: modules
Reference: list | Book Index | Reference: modules


Reference: modules

Previous: Reference: make Chapter 20
Program Debugging 		Next: Reference: next

modules

modules

List object files for which debugging data is available.

Previous: Reference: make | UNIX in a Nutshell: System V Edition | Next: Reference: next
Reference: make | Book Index | Reference: next


Reference: next

Previous: Reference: modules Chapter 20
Program Debugging 		Next: Reference: nexti

next

next [n]

Execute next n source lines. Default is 1. next doesn't go into functions.

Previous: Reference: modules | UNIX in a Nutshell: System V Edition | Next: Reference: nexti
Reference: modules | Book Index | Reference: nexti


Reference: nexti

Previous: Reference: next Chapter 20
Program Debugging 		Next: Reference: print

nexti

nexti

Same as next, but do a single instruction instead of a source line.

Previous: Reference: next | UNIX in a Nutshell: System V Edition | Next: Reference: print
Reference: next | Book Index | Reference: print


Reference: print

Previous: Reference: nexti Chapter 20
Program Debugging 		Next: Reference: pwd

print

print expressions

Print the values of one or more comma-separated expressions.

Previous: Reference: nexti | UNIX in a Nutshell: System V Edition | Next: Reference: pwd
Reference: nexti | Book Index | Reference: pwd


Reference: pwd

Previous: Reference: print Chapter 20
Program Debugging 		Next: Reference: quit

pwd

pwd

Print the working directory for dbx.

Previous: Reference: print | UNIX in a Nutshell: System V Edition | Next: Reference: quit
Reference: print | Book Index | Reference: quit


Reference: quit

Previous: Reference: pwd Chapter 20
Program Debugging 		Next: Reference: replay

quit

quit

Exit dbx.

Previous: Reference: pwd | UNIX in a Nutshell: System V Edition | Next: Reference: replay
Reference: pwd | Book Index | Reference: replay


Reference: replay

Previous: Reference: quit Chapter 20
Program Debugging 		Next: Reference: rerun

replay

replay [-n]

A save-restore combination. The default action (n is 1) works like an undo.

Previous: Reference: quit | UNIX in a Nutshell: System V Edition | Next: Reference: rerun
Reference: quit | Book Index | Reference: rerun


Reference: rerun

Previous: Reference: replay Chapter 20
Program Debugging 		Next: Reference: restore

rerun

rerun [arguments]

Without arguments, redo the previous run command (and its arguments). Otherwise, this command is the same as run.

Previous: Reference: replay | UNIX in a Nutshell: System V Edition | Next: Reference: restore
Reference: replay | Book Index | Reference: restore


Reference: restore

Previous: Reference: rerun Chapter 20
Program Debugging 		Next: Reference: return

restore

restore [file]

Redo dbx commands stored via save in file or in special buffer.

Previous: Reference: rerun | UNIX in a Nutshell: System V Edition | Next: Reference: return
Reference: rerun | Book Index | Reference: return


Reference: return

Previous: Reference: restore Chapter 20
Program Debugging 		Next: Reference: run

return

return [procedure]

Continue until a return to procedure (or current procedure) is called.

Previous: Reference: restore | UNIX in a Nutshell: System V Edition | Next: Reference: run
Reference: restore | Book Index | Reference: run


Reference: run

Previous: Reference: return Chapter 20
Program Debugging 		Next: Reference: save

run

run [arguments]

Begin executing the object file, passing optional command-line arguments. The arguments can include input or output redirection to a named file.

Previous: Reference: return | UNIX in a Nutshell: System V Edition | Next: Reference: save
Reference: return | Book Index | Reference: save


Reference: save

Previous: Reference: run Chapter 20
Program Debugging 		Next: Reference: set

save

save [-n] [file]

Store dbx commands entered since last run, rerun, or debug. Or save all but the last n. Save either to file or to a buffer accessed by restore.

Previous: Reference: run | UNIX in a Nutshell: System V Edition | Next: Reference: set
Reference: run | Book Index | Reference: set


Reference: set

Previous: Reference: save Chapter 20
Program Debugging 		Next: Reference: setenv

set

set var [= expr]

Define value expr for variable var. See also unset. Built-in variables include:

$frame

If set to an address, use the stack frame it points to. (Useful for kernel debugging.)

$hexitem

When set, print hexadecimal values for specified item. item can be chars, ints, offsets, or strings.

$listwindow

Default number of lines to show using list command (default is 10).

$mapaddrs

When set, start mapping addresses; when unset, stop. (Useful for kernel debugging.)

$unsafecall

When set, turn off type checking of parameters in call statements. Use with care.

$unsafeassign

When set, turn off type checking in assign statements. Use with care.

Previous: Reference: save | UNIX in a Nutshell: System V Edition | Next: Reference: setenv
Reference: save | Book Index | Reference: setenv


Reference: setenv

Previous: Reference: set Chapter 20
Program Debugging 		Next: Reference: sh

setenv

setenv VAR string

Set environment variable VAR to string.

Previous: Reference: set | UNIX in a Nutshell: System V Edition | Next: Reference: sh
Reference: set | Book Index | Reference: sh


Reference: sh

Previous: Reference: setenv Chapter 20
Program Debugging 		Next: Reference: source

sh

sh command

Pass command to the shell for execution.

Previous: Reference: setenv | UNIX in a Nutshell: System V Edition | Next: Reference: source
Reference: setenv | Book Index | Reference: source


Reference: source

Previous: Reference: sh Chapter 20
Program Debugging 		Next: Reference: status

source

source file

Read commands for dbx from file. E.g., file might be created by a previous status command.

Previous: Reference: sh | UNIX in a Nutshell: System V Edition | Next: Reference: status
Reference: sh | Book Index | Reference: status


Reference: status

Previous: Reference: source Chapter 20
Program Debugging 		Next: Reference: step

status

status [> file]

Show active trace, stop, and when commands; store output in file.

Previous: Reference: source | UNIX in a Nutshell: System V Edition | Next: Reference: step
Reference: source | Book Index | Reference: step


Reference: step

Previous: Reference: status Chapter 20
Program Debugging 		Next: Reference: step

step

step [n]

Execute n source lines. Default is 1. step goes into functions. See also next.

Previous: Reference: status | UNIX in a Nutshell: System V Edition | Next: Reference: step
Reference: status | Book Index | Reference: step


Reference: step

Previous: Reference: step Chapter 20
Program Debugging 		Next: Reference: stepi

step

step up

Take program up and out from current function; resume with the line after the function call.

Previous: Reference: step | UNIX in a Nutshell: System V Edition | Next: Reference: stepi
Reference: step | Book Index | Reference: stepi


Reference: stepi

Previous: Reference: step Chapter 20
Program Debugging 		Next: Reference: stop

stepi

stepi

Same as step, but do a single instruction instead of a source line.

Previous: Reference: step | UNIX in a Nutshell: System V Edition | Next: Reference: stop
Reference: step | Book Index | Reference: stop


Reference: stop

Previous: Reference: stepi Chapter 20
Program Debugging 		Next: Reference: stopi

stop

stop restriction [if cond]

Stop execution if specified restriction is true. See trace about cond.

Restriction

at n

Source line n is reached.

if cond

Condition cond is true.

in func

Procedure or function func is called.

inclass class

Each method of C++ class is called.

infunction func

Top-level function in a C++ module is called.

inmethod member

Named member of any C++ class is called.

var

Variable var has changed.

Previous: Reference: stepi | UNIX in a Nutshell: System V Edition | Next: Reference: stopi
Reference: stepi | Book Index | Reference: stopi


Reference: stopi

Previous: Reference: stop Chapter 20
Program Debugging 		Next: Reference: trace

stopi

stopi restriction [if cond]

Similar to stop, but set a stop using machine instruction addresses. See trace about cond.

Restriction

at address

Stop execution at address

var

Stop execution if value of variable var changes.

Previous: Reference: stop | UNIX in a Nutshell: System V Edition | Next: Reference: trace
Reference: stop | Book Index | Reference: trace


Reference: trace

Previous: Reference: stopi Chapter 20
Program Debugging 		Next: Reference: tracei

trace

trace [restriction] [if cond]

Report tracing information as program is executed, according to the restriction. With no arguments, all source lines are printed before being executed. cond is a Boolean expression; if it evaluates to false, then the tracing information is not printed.

Restriction

in func

Report while executing func.

inclass class

Print name of function that called any member of class.

infunction func

Print name of function that called any top-level C++ func.

inmethod member

Print name of function that called member of any class.

expr at n

Print value of expr each time line n is reached.

func

Print name of function that called func.

n

Show source line n before executing it.

var

Print value of var each time it changes.

var [in func]

Same as above, but print information only while executing from within the specified procedure or function.

Previous: Reference: stopi | UNIX in a Nutshell: System V Edition | Next: Reference: tracei
Reference: stopi | Book Index | Reference: tracei


Reference: tracei

Previous: Reference: trace Chapter 20
Program Debugging 		Next: Reference: unalias

tracei

tracei [restriction] [if cond]

Similar to trace, but trace using machine instruction addresses.

Restriction

addr

Start tracing at address addr.

var [at addr]

Start tracing variable var at address addr.

Previous: Reference: trace | UNIX in a Nutshell: System V Edition | Next: Reference: unalias
Reference: trace | Book Index | Reference: unalias


Reference: unalias

Previous: Reference: tracei Chapter 20
Program Debugging 		Next: Reference: undisplay

unalias

unalias name

Remove the alias name. See also alias.

Previous: Reference: tracei | UNIX in a Nutshell: System V Edition | Next: Reference: undisplay
Reference: tracei | Book Index | Reference: undisplay


Reference: undisplay

Previous: Reference: unalias Chapter 20
Program Debugging 		Next: Reference: unset

undisplay

undisplay [expressions]

Stop displaying expressions (see display). expression can be a number, in which case it refers to the item-number in a display list.

Previous: Reference: unalias | UNIX in a Nutshell: System V Edition | Next: Reference: unset
Reference: unalias | Book Index | Reference: unset


Reference: unset

Previous: Reference: undisplay Chapter 20
Program Debugging 		Next: Reference: up

unset

unset var

Remove the debugger variable var. See also set.

Previous: Reference: undisplay | UNIX in a Nutshell: System V Edition | Next: Reference: up
Reference: undisplay | Book Index | Reference: up


Reference: up

Previous: Reference: unset Chapter 20
Program Debugging 		Next: Reference: use

up

up [n]

Move current function up n levels on stack. Default is 1. See also down.

Previous: Reference: unset | UNIX in a Nutshell: System V Edition | Next: Reference: use
Reference: unset | Book Index | Reference: use


Reference: use

Previous: Reference: up Chapter 20
Program Debugging 		Next: Reference: whatis

use

use [directories]

Define one or more directories to search when looking for source files. With no argument, print the current search directories.

Previous: Reference: up | UNIX in a Nutshell: System V Edition | Next: Reference: whatis
Reference: up | Book Index | Reference: whatis


Reference: whatis

Previous: Reference: use Chapter 20
Program Debugging 		Next: Reference: when

whatis

whatis [-r] name

Print the declaration of the identifier, class, or type name. -r recursively prints the declarations of inherited classes.

Previous: Reference: use | UNIX in a Nutshell: System V Edition | Next: Reference: when
Reference: use | Book Index | Reference: when


Reference: when

Previous: Reference: whatis Chapter 20
Program Debugging 		Next: Reference: where

when

when restriction commands

Execute one or more dbx commands (separated by semi-colons) when restriction is true. See stop for list of restrictions.

Previous: Reference: whatis | UNIX in a Nutshell: System V Edition | Next: Reference: where
Reference: whatis | Book Index | Reference: where


Reference: where

Previous: Reference: when Chapter 20
Program Debugging 		Next: Reference: whereis

where

where [n]

List all active functions on the stack, or only the top n.

Previous: Reference: when | UNIX in a Nutshell: System V Edition | Next: Reference: whereis
Reference: when | Book Index | Reference: whereis


Reference: whereis

Previous: Reference: where Chapter 20
Program Debugging 		Next: Reference: which

whereis

whereis identifier

Print the fully-qualified name of symbols that match identifier.

Previous: Reference: where | UNIX in a Nutshell: System V Edition | Next: Reference: which
Reference: where | Book Index | Reference: which


Reference: which

Previous: Reference: whereis Chapter 20
Program Debugging 		Next: Reference: search

which

which identifier

Print the fully-qualified name of identifier.

Previous: Reference: whereis | UNIX in a Nutshell: System V Edition | Next: Reference: search
Reference: whereis | Book Index | Reference: search


Reference: search

Previous: Reference: which Chapter 20
Program Debugging

search

search

Specify a search pattern of the form /regexp/ (to search forward for a regular expression) or ?regexp? (to search backward). The matched line becomes the current line.

Previous: Reference: which | UNIX in a Nutshell: System V Edition |
Reference: which | Book Index | Reference: addr1/


Reference: addr1/

Previous: Reference: search Chapter 20
Program Debugging 		Next: Reference: address

addr1/

addr1/

Print contents of memory starting at the address addr1. Stop printing when a second address is reached or when n items have been printed, as shown by the syntax lines below:

addr1, addr2/[mode] addr1/[n] [mode]

mode specifies the output format. Default is X. Addresses may be . (next address), &addr (symbolic address), and $rn (register n). Addresses may include the symbols +, -, and * (indirection).

Mode

b

Print a byte in octal.

c

Print a byte as a character.

d

Print a short word in decimal.

D

Print a long word in decimal.

f

Print a single-precision real number.

F

Print a double-precision real number.

i

Print a machine instruction.

o

Print a short word in octal.

O

Print a long word in octal.

s

Print a string as characters terminated by a null byte.

x

Print a short word in hexadecimal.

X

Print a long word in hexadecimal.

Previous: Reference: search | UNIX in a Nutshell: System V Edition | Next: Reference: address
Reference: search | Book Index | Reference: address


Reference: address

Chapter 20
Program Debugging 		Next: 20. Program Debugging

address

address =  [mode]

Display the value of address.

 | UNIX in a Nutshell: System V Edition | Next: 20. Program Debugging
Reference: addr1/ | Book Index | 20. Program Debugging


[Chapter 1] Introduction

Previous: We'd Like to Hear From You Chapter 1 Next: 1.2 Bundling

1. Introduction

Contents:
Merging the Traditions
Bundling
What's in the Quick Ref
Beginner's Guide
Guide for Users of BSD-derived Systems

The UNIX operating system originated from AT&T (now USL) in the early 1970's. Because UNIX was able to run on different hardware from different vendors, this encouraged developers to modify UNIX and distribute it as their own value-added version of UNIX. Separate UNIX traditions evolved as a result: USL's System V, Berkeley Standard Distribution (BSD, from the University of California, Berkeley), Xenix, etc.

1.1 Merging the Traditions

Today, UNIX developers are trying to blend the different traditions back into a more standard version. (The ongoing work on POSIX, an international standard based on System V and BSD, is influencing this movement.) This quick reference describes two systems that offer what many people consider to be a "more standard" version of UNIX: System V Release 4 (SVR4) and Solaris 2.0.

SVR4, which was developed jointly by USL (a division of AT&T) and Sun Microsystems, has merged features from BSD and SVR3. This adds about two dozen BSD commands (plus some new SVR4 commands) to the basic UNIX command set. In addition, SVR4 provides a BSD Compatibility Package, a kind of "second string" command group. This package includes some of the most fundamental BSD commands, and its purpose is to help users of BSD-derived systems make the transition to SVR4.

Solaris 2.0 is a distributed computing environment from SunSoft (a division of Sun Microsystems). The history of Solaris 2.0 is more complicated.

Solaris 2.0 includes the SunOS 5.0 operating system plus additional features such as OpenWindows. SunOS 5.0, in turn, merges SunOS 4.1 and SVR4. Most of the new content comes from SVR4. As a result, Solaris 2.0 is based on SVR4 but contains additional BSD/SunOS features. To help in the transition from the old (largely BSD-based) SunOS, Solaris 2.0 provides the BSD/SunOS Compatibility Package and the Binary Compatibility Package.

Previous: We'd Like to Hear From You | UNIX in a Nutshell: System V Edition | Next: 1.2 Bundling
We'd Like to Hear From You | Book Index | 1.2 Bundling


[Chapter 1] 1.2 Bundling

Previous: 1.1 Merging the Traditions Chapter 1
Introduction 		Next: 1.3 What's in the Quick Ref

1.2 Bundling

Another issue affecting UNIX systems is the idea of bundling. UNIX has many features-sometimes more than you need to use. Nowadays, UNIX systems are usually split, or bundled, into various component packages. Some components are included automatically in the system you buy; others are optional-you get them only if you pay extra. Bundling lets you to select only the components you need. Typical bundling includes the following:

Basic System

Basic commands and utilities.

Programming

Compilers, debuggers, and libraries.

Text Processing

Troff, macros, and related tools.

Networking

Utilities for connecting to remote machines, including commands like rlogin, rcp, etc.

Windowing

Graphical user interfaces such as OPEN LOOK and Motif.

Bundling depends on the vendor. For example, Solaris 2.0 is shipped with OpenWindows, a windowing environment based on OPEN LOOK; you don't have to buy it as a separate package. For other vendors, the windowing package may be an extra-cost option. Similarly, some vendors ship text processing tools or compilers, and others don't.

Previous: 1.1 Merging the Traditions | UNIX in a Nutshell: System V Edition | Next: 1.3 What's in the Quick Ref
1.1 Merging the Traditions | Book Index | 1.3 What's in the Quick Ref


[Chapter 1] 1.3 What's in the Quick Ref

Previous: 1.2 Bundling Chapter 1
Introduction 		Next: 1.4 Beginner's Guide

1.3 What's in the Quick Ref

This guide presents the major features of generic SVR4, plus a few extras from the compatibility packages and from Solaris 2.0. In addition, this guide presents sections on emacs and RCS. Although they are not part of the standard SVR4 distribution, they are found on many UNIX systems because they are useful add-ons.

But keep in mind: if your system doesn't include all the component packages, there will be commands in this quick ref that you won't be able to find on your system.

The summary of UNIX commands in Section 2 makes up a large part of this book. Only user/programmer commands are included; administrative commands are ignored. Section 2 describes the following set:

  • Commands from SVR3.

  • New commands and options in SVR4.

  • Selected commands from the compatibility packages and from Solaris 2.0, such as dbx (the debugger) and openwin (the start-up program for OpenWindows).

SVR3 users should note that many commands listed in Section 2 are not in SVR3. These include:

apropos | face | iconv | mcs | rksh | users
atq | fmli | keylogin | mkmsgs | sccs | uudecode
atrm | fmt | keylogout | nawk | script | uuencode
chkey | fmtmsg | ksh | notify | soelim | uuglist
clear | fold | ldd | openwin | srchtxt | vacation
cof2elf | gcore | lpq | pic | strings | w
compress | gencat | lpr | printenv | talk | whatis
ctags | gettxt | lprm | printf | truss | which
dbx | gprof | lprof | ptx | tset | whoami
download | head | lptest | relogin | uncompress | whois
dpost | hostid | mailalias | reset | uptime | zcat
exstr | hostname |  |  |  |

Previous: 1.2 Bundling | UNIX in a Nutshell: System V Edition | Next: 1.4 Beginner's Guide
1.2 Bundling | Book Index | 1.4 Beginner's Guide


[Chapter 1] 1.4 Beginner's Guide

Previous: 1.3 What's in the Quick Ref Chapter 1
Introduction 		Next: 1.5 Guide for Users of BSD-derived Systems

1.4 Beginner's Guide

If you're just beginning to work on a UNIX system, the abundance of commands might prove daunting. To help orient you, the following tables present a small sampling of commands on various topics.

1.4.1 Communication

cu | Connect to UNIX system.
ftp | File transfer protocol.
login | Sign on to UNIX.
mailx | Read or send mail.
rlogin | Sign on to remote UNIX.
talk | Write to other terminals.
telnet | Connect to another system.
vacation | Respond to mail automatically.
write | Write to other terminals.

1.4.2 Comparisons

cmp | Compare two files.
comm | Compare items in files.
diff | Compare two files.
diff3 | Compare three files.
dircmp | Compare directories.
sdiff | Compare two files, side by side.

1.4.3 File Management

cat | Join files or display them.
cd | Change directory.
chmod | Change access modes on files.
cp | Copy files.
csplit | Break files at specific locations.
file | Determine a file's type.
head | Show the first few lines of a file.
install | Set up system files.
ln | Create filename aliases.
ls | List files or directories.
mkdir | Create a directory.
more | Display files by screenful.
mv | Move or rename files or directories.
pwd | Print your working directory.
rcp | Copy files to remote system.
rm | Remove files.
rmdir | Remove directories.
split | Split files evenly.
tail | Show the last few lines of a file.
wc | Count lines, words, and characters.

1.4.4 Miscellaneous

banner | Make posters from words.
bc | Precision calculator.
cal | Display calendar.
calendar | Check for reminders.
clear | Clear the screen.
kill | Terminate a running command.
man | Get information on a command.
nice | Reduce a job's priority.
nohup | Preserve a job after logging out.
passwd | Set password.
script | Produce a transcript of your login session.
spell | Report misspelled words.
su | Become a superuser.

1.4.5 Printing

cancel | Cancel a printer request.
lp | Send to the printer.
lpstat | Get printer status.
pr | Format and paginate for printing.

1.4.6 Programming

cb | C source code "beautifier."
cc | C compiler.
cflow | C function flowchart.
ctags | C function references.
ctrace | C debugger.
cxref | C cross-references.
lint | C debugger.
ld | Link editor.
lex | Lexical analyzer.
make | Execute commands in a specified order.
od | Dump input in various formats.
sdb | Symbolic debugger.
strip | Remove data from an object file.
truss | Trace signals and system calls.
yacc | Compiler used with lex.

1.4.7 Searching

egrep | Extended version of grep.
fgrep | Search files for literal words.
find | Search the system for filenames.
grep | Search files for text patterns.
strings | Search binary files for text patterns.

1.4.8 Shell Programming

echo | Repeat input on the output.
expr | Perform arithmetic and comparisons.
line | Read a line of input.
sleep | Pause during processing.
test | Test a condition.

1.4.9 Storage

compress | Compress files to free up space.
cpio | Copy archives in or out.
pack | Pack files to free up space.
pcat | Display contents of packed files.
tar | Tape archiver.
uncompress | Expand compressed (.Z) files.
unpack | Expand packed (.z) files.
zcat | Display contents of compressed files.

1.4.10 System Status

at | Execute commands later.
chgrp | Change file group.
chown | Change file owner.
crontab | Automate commands.
date | Display or set date.
df | Show free disk space.
du | Show disk usage.
env | Show environment variables.
finger | Point out information about users.
ps | Show processes.
ruptime | Show loads on working systems.
shutdown | Revert to single-user mode.
stty | Set or display terminal settings.
who | Show who is logged on.

1.4.11 Text Processing

cut | Select columns for display.
ex | Line-editor underlying vi.
fmt | Produce roughly uniform line lengths.
fold | Produce exactly uniform line lengths.
join | Merge different columns into a database.
nawk | New version of awk (pattern-matching language for database files).
paste | Merge columns or switch order.
sed | Noninteractive text editor.
sort | Sort or merge files.
tr | Translate (redefine) characters.
uniq | Find repeated or unique lines in a file.
vi | Visual text editor.
xargs | Process many arguments in manageable portions.

1.4.12 Troff

All but deroff are in the compatibility packages.

deroff | Remove troff codes.
eqn | Preprocessor for equations.
nroff | Formatter for terminal display.
pic | Preprocessor for line graphics.
tbl | Preprocessor for tables.
troff | Formatter for typesetting.

Previous: 1.3 What's in the Quick Ref | UNIX in a Nutshell: System V Edition | Next: 1.5 Guide for Users of BSD-derived Systems
1.3 What's in the Quick Ref | Book Index | 1.5 Guide for Users of BSD-derived Systems


[Chapter 1] 1.5 Guide for Users of BSD-derived Systems

Previous: 1.4 Beginner's Guide Chapter 1
Introduction 		Next: 2. UNIX Commands

1.5 Guide for Users of BSD-derived Systems

Those of you making a transition to SVR4 from a BSD-derived system should note that BSD commands reside in your system's /usr/ucb directory. This is especially important when using certain commands, because the compatibility packages include several commands that have an existing counterpart in SVR4, and the two versions work slightly differently. If your PATH variable specifies /usr/ucb before the SVR4 command directories (e.g., /usr), you'll end up running the BSD version of the command. Check your PATH variable to make sure that you're getting what you want. The commands that have both BSD and SVR4 variants include:

basename | du | ln | sum
cc | echo | ls | test
chown | groups | ps | tr
deroff | install | shutdown | vacation
df | ld | stty |

This guide describes the SVR4 version of the above commands.

Previous: 1.4 Beginner's Guide | UNIX in a Nutshell: System V Edition | Next: 2. UNIX Commands
1.4 Beginner's Guide | Book Index | 2. UNIX Commands


[Chapter 2] UNIX Commands

Previous: 1.5 Guide for Users of BSD-derived Systems Chapter 2 Next: 3. The UNIX Shell: An Overview

2. UNIX Commands

Contents:
Alphabetical Summary of Commands

This section presents the UNIX commands of interest to users and programmers. Most of these commands appear in the "Commands" section of the User's Reference Manual and Programmer's Reference Manual for UNIX System V Release 4 (SVR4). This section describes additional commands from the compatibility packages; these commands are prefixed with /usr/ucb, the name of the directory in which they reside. With some exceptions, these commands are only in SVR4. Also included here are commands specific to Solaris 2.0, such as the debugger dbx and the start-up script for OpenWindows, openwin.

Each entry is labeled with the command name on the outer edge of the page. The syntax line is followed by a brief description and a list of all available options. (Obsolete options have been marked as "SVR3 only.") Many commands come with examples at the end of the entry. If you need only a quick reminder or suggestion about a command, you can skip directly to the examples.

Some options can be invoked only by a user with special system privileges. Such a person is often called a superuser. In this book we use the term privileged user instead.

Typographic conventions for describing command syntax are listed in the Preface. For additional help in locating commands, see the Command Index (Section 22) at the back of this guide.

2.1 Alphabetical Summary of Commands

  • admin
  • apropos
  • ar
  • as
  • at
  • atq
  • atrm
  • awk
  • banner
  • basename
  • batch
  • bc
  • bdiff
  • bfs
  • cal
  • calendar
  • cancel
  • cat
  • cb
  • cc
  • cd
  • cdc
  • cflow
  • chgrp
  • chkey
  • chmod
  • chown
  • clear
  • cmp
  • cof2elf
  • col
  • comb
  • comm
  • compress
  • cp
  • cpio
  • crontab
  • crypt
  • cscope
  • csh
  • csplit
  • ctags
  • ctrace
  • cu
  • cut
  • cxref
  • date
  • dbx
  • dc
  • dd
  • delta
  • deroff
  • df
  • diff
  • diff3
  • diffmk
  • dircmp
  • dirname
  • dis
  • download
  • dpost
  • du
  • echo
  • ed
  • edit
  • egrep
  • env
  • eqn
  • ex
  • expr
  • exstr
  • face
  • factor
  • false
  • fgrep
  • file
  • find
  • finger
  • fmli
  • fmt
  • fmtmsg
  • fold
  • ftp
  • gcore
  • gencat
  • get
  • getopts
  • gettxt
  • gprof
  • grep
  • groups
  • head
  • help
  • hostid
  • hostname
  • iconv
  • id
  • install
  • ipcrm
  • ipcs
  • ismpx
  • join
  • jsh
  • jterm
  • jwin
  • keylogin
  • keylogout
  • kill
  • ksh
  • layers
  • ld
  • ldd
  • lex
  • line
  • lint
  • ln
  • login
  • logname
  • lorder
  • lp
  • lpq
  • lpr
  • lprm
  • lprof
  • lpstat
  • lptest
  • ls
  • m4
  • m4
  • mail
  • mailalias
  • mailx
  • make
  • makekey
  • man
  • mcs
  • mesg
  • mkdir
  • mkmsgs
  • more
  • mv
  • nawk
  • newform
  • newgrp
  • news
  • nice
  • nl
  • nm
  • nohup
  • notify
  • nroff
  • od
  • openwin
  • pack
  • page
  • passwd
  • paste
  • pcat
  • pg
  • pic
  • pr
  • printenv
  • printf
  • prof
  • prs
  • ps
  • ptx
  • pwd
  • rcp
  • red
  • regcmp
  • relogin
  • reset
  • rksh
  • rlogin
  • rm
  • rmdel
  • rmdir
  • rsh
  • rsh
  • ruptime
  • rwho
  • sact
  • sccs
  • sccsdiff
  • script
  • sdb
  • sdiff
  • sed
  • sh
  • shl
  • shutdown
  • size
  • sleep
  • soelim
  • sort
  • spell
  • split
  • srchtxt
  • strings
  • strip
  • stty
  • su
  • sum
  • tabs
  • tail
  • talk
  • tar
  • tbl
  • tee
  • telnet
  • test
  • time
  • timex
  • touch
  • tput
  • tr
  • troff
  • true
  • truss
  • tset
  • tsort
  • tty
  • umask
  • uname
  • uncompress
  • unget
  • uniq
  • units
  • unpack
  • uptime
  • users
  • uucp
  • uudecode
  • uuencode
  • uuglist
  • uulog
  • uuname
  • uupick
  • uustat
  • uuto
  • uux
  • vacation
  • val
  • vc
  • vedit
  • vi
  • view
  • w
  • wait
  • wall
  • wc
  • what
  • whatis
  • which
  • who
  • whoami
  • whois
  • write
  • xargs
  • yacc
  • zcat

Previous: 1.5 Guide for Users of BSD-derived Systems | UNIX in a Nutshell: System V Edition | Next: 3. The UNIX Shell: An Overview
1.5 Guide for Users of BSD-derived Systems | Book Index | 3. The UNIX Shell: An Overview


[Chapter 3] The UNIX Shell: An Overview

Previous: 2.1 Alphabetical Summary of Commands Chapter 3 Next: 3.2 Purpose of the Shell

3. The UNIX Shell: An Overview

Contents:
Introduction to the Shell
Purpose of the Shell
Shell Flavors
Common Features
Differing Features

For novice users, this section presents basic concepts about the UNIX shell. For advanced users, this section also summarizes the major similarities and differences between the Bourne, Korn, and C shells. Details on the three shells are provided in Sections 4 and 5.

The following topics are presented:

  • Introduction to the shell

  • Purpose of the shell

  • Shell flavors

  • Common features

  • Differing features

3.1 Introduction to the Shell

Let's suppose that the UNIX operating system is a car. When you drive, you issue a variety of "commands": you turn the steering wheel, press the accelerator, or press the brake. But how does the car translate your commands into the action you want? Through the car's drive mechanism, which can be thought of as the car's user interface. Cars can be equipped with front-wheel drive, rear-wheel drive, four-wheel drive, and sometimes combinations of these.

The shell can be thought of as the user interface to UNIX, and by the same token, several shells are available in UNIX. Some systems provide only one shell. Many provide more than one for you to choose from. Each shell has different features, but all of them affect how commands will be interpreted and provide tools to create your UNIX environment.

The shell is simply a program that allows the system to understand your commands. (That's why the shell is often called a command interpreter.) For many users, the shell works invisibly-"behind the scenes." Your only concern is that the system do what you tell it to do; you don't care about the inner workings. In our car analogy, this is comparable to pressing the brake. Most of us don't care whether the "user interface" involves disk brakes or drum brakes, as long as the car stops.

Previous: 2.1 Alphabetical Summary of Commands | UNIX in a Nutshell: System V Edition | Next: 3.2 Purpose of the Shell
2.1 Alphabetical Summary of Commands | Book Index | 3.2 Purpose of the Shell


[Chapter 3] 3.2 Purpose of the Shell

Previous: 3.1 Introduction to the Shell Chapter 3
The UNIX Shell: An Overview 		Next: 3.3 Shell Flavors

3.2 Purpose of the Shell

There are three main uses for the shell:

  • Interactive use

  • Customization of your UNIX session

  • Programming

3.2.1 Interactive Use

When the shell is used interactively, the system waits for you to type a command at the UNIX prompt. Your commands can include special symbols that let you abbreviate filenames or redirect input and output.

3.2.2 Customization of Your UNIX Session

A UNIX shell defines variables to control the behavior of your UNIX session. Setting these variables will tell the system, for example, which directory to use as your home directory, or the file in which to store your mail. Some variables are preset by the system; you can define others in start-up files that are read when you log in. Start-up files can also contain UNIX commands or special shell commands. These will be executed every time you log in.

3.2.3 Programming

UNIX shells provide a set of special (or built-in) commands that can be used to create programs called shell scripts. In fact, many built-in commands can be used interactively like UNIX commands, and UNIX commands are frequently used in shell scripts. Scripts are useful for executing a series of individual commands. This is similar to BATCH files in MS-DOS. Scripts can also execute commands repeatedly (in a loop) or conditionally (if-else), as in many high-level programming languages.

Previous: 3.1 Introduction to the Shell | UNIX in a Nutshell: System V Edition | Next: 3.3 Shell Flavors
3.1 Introduction to the Shell | Book Index | 3.3 Shell Flavors


[Chapter 3] 3.3 Shell Flavors

Previous: 3.2 Purpose of the Shell Chapter 3
The UNIX Shell: An Overview 		Next: 3.4 Common Features

3.3 Shell Flavors

Many different UNIX shells are available. This quick reference describes the three most popular shells:

  • The Bourne (or standard) shell, the most compact shell but also the simplest.

  • The Korn shell, a superset of the Bourne shell that lets you edit the command line.

  • The C shell, which uses C syntax and has many conveniences.

Most systems have more than one shell, and people will often use the Bourne shell for writing shell scripts and will use another shell for interactive use.

The /etc/passwd file determines which shell takes effect during your interactive UNIX session. When you log in, the system checks your entry in /etc/passwd. The last field of each entry calls a program to run as the default shell. For example:

If the program | Your shell will be the:
name is: |
/bin/sh | Bourne shell
/bin/rsh | Restricted Bourne shell
/bin/jsh | Bourne shell, including job control
/bin/ksh | Korn shell
/bin/rksh | Restricted Korn shell
/bin/csh | C shell

You can change to another shell by typing the program name at the command line. For example, to change from the Bourne shell to the C shell, type:

$ exec csh

Previous: 3.2 Purpose of the Shell | UNIX in a Nutshell: System V Edition | Next: 3.4 Common Features
3.2 Purpose of the Shell | Book Index | 3.4 Common Features


[Chapter 3] 3.4 Common Features

Previous: 3.3 Shell Flavors Chapter 3
The UNIX Shell: An Overview 		Next: 3.5 Differing Features

3.4 Common Features

The table below is a sampling of features that are common to the Bourne, Korn, and C shells. Note that the Korn shell is an enhanced version of the Bourne shell; therefore, the Korn shell includes all features of the Bourne shell, plus some others. The commands bg, fg, jobs, stop, and suspend are available only on systems that support job control.

Symbol/ | Meaning/Action
Command |
> | Redirect output.
>> | Append to file.
< | Redirect input.
<< | "Here" document (redirect input).
| | Pipe output.
& | Run process in background.
; | Separate commands on same line.
* | Match any character(s) in filename.
? | Match single character in filename.
[ ] | Match any characters enclosed.
( ) | Execute in subshell.
` ` | Substitute output of enclosed command.
" " | Partial quote (allows variable and command expansion).
' ' | Full quote (no expansion).
\ | Quote following character.
$var | Use value for variable.
$$ | Process id.
$0 | Command name.
$n | nth argument (0<n<9).
$* | All arguments as a simple word.
# | Begin comment.
bg | Background execution.
break | Break from loop statements.
cd | Change directories
continue | Resume a program loop.
echo | Display output.
eval | Evaluate arguments.
exec | Execute a new shell.
fg | Foreground execution.
jobs | Show active jobs.
kill | Terminate running jobs.
newgrp | Change to a new group.
shift | Shift positional parameters.
stop | Suspend a background job.
suspend | Suspend a foreground job.
time | Time a command.
umask | Set or list file permissions.
unset | Erase variable or function definitions.
wait | Wait for a background job to finish.

Previous: 3.3 Shell Flavors | UNIX in a Nutshell: System V Edition | Next: 3.5 Differing Features
3.3 Shell Flavors | Book Index | 3.5 Differing Features


[Chapter 3] 3.5 Differing Features

Previous: 3.4 Common Features Chapter 3
The UNIX Shell: An Overview 		Next: 4. The Bourne Shell and Korn Shell

3.5 Differing Features

The table below is a sampling of features that are different among the three shells.

sh | ksh | csh | Meaning/Action
$ | $ | % | Prompt.
 |  | >! | Force redirection.
 |  | >>! | Force append.
> file 2>&1 | > file 2>&1 | >& file | Combine stdout and stderr.
 |  | { } | Expand elements in list.
` ` | $( ) | ` ` | Substitute output of enclosed command.
$HOME | $HOME | $home | Home directory.
 | ~ | ~ | Home directory symbol.
var=value | var=value | set var=value | Variable assignment.
export var | export var=val | setenv var val | Set environment variable.
 | ${nn} |  | More than 9 args can be referenced.
"$@" | "$@" |  | All args as separate words.
$# | $# | $#argv | Number of arguments.
$? | $? | $status | Exit status.
$! | $! |  | Background exit status.
$- | $- |  | Current options.
. file | . file | source file | Read commands in file.
 | alias x=y | alias x y | Name x stands for y.
case | case | switch/case | Choose alternatives.
 | cd ~- | popd/pushd | Switch directories.
done | done | end | End a loop statement.
esac | esac | endsw | End case or switch.
exit [n] | exit [n] | exit [(expr)] | Exit with a status.
for/do | for/do | foreach | Loop through variables.
 | print -r | glob | Ignore echo escapes.
hash | alias -t | hashstat | Display hashed commands (tracked aliases).
hash cmds | alias -t cmds | rehash | Remember command locations.
hash -r |  | unhash | Forget command locations.
 | history | history | List previous commands.
 | r | !! | Redo previous command.
 | r str | !str | Redo command that starts with str.
 | r x=y cmd | !cmd:s/x/y/ | Edit command, then execute.
if [ $i -eq 5 ] | if ((i==5)) | if ($i==5) | Sample if statement.
fi | fi | endif | End if statement.
ulimit | ulimit | limit | Set resource limits.
pwd | pwd | dirs | Print working directory.
read | read | $< | Read from terminal.
trap 2 | trap 2 | onintr | Ignore interrupts.
 | unalias | unalias | Remove aliases.
until | until |  | Begin until loop.
while/do | while/do | while | Begin while loop.

Previous: 3.4 Common Features | UNIX in a Nutshell: System V Edition | Next: 4. The Bourne Shell and Korn Shell
3.4 Common Features | Book Index | 4. The Bourne Shell and Korn Shell


[Chapter 4] The Bourne Shell and Korn Shell

Previous: 3.5 Differing Features Chapter 4 Next: 4.2 Syntax

4. The Bourne Shell and Korn Shell

Contents:
Overview of Features
Syntax
Variables
Arithmetic Expressions
Command History
Built-in Commands (Bourne and Korn Shell)
Job Control
Invoking the Shell
Restricted Shells

This section presents the following topics:

  • Overview of features

  • Syntax

  • Variables

  • Arithmetic expressions (Korn shell only)

  • Command history (Korn shell only)

  • Built-in commands

  • Job control

  • Invoking the shell

  • Restricted shells

4.1 Overview of Features

The Bourne shell is the standard shell and provides the following features:

  • Input/output redirection.

  • Wildcard characters (metacharacters) for filename abbreviation.

  • Shell variables for customizing your environment.

  • A built-in command set for writing shell programs.

  • Job control (beginning in SVR4).

The Korn shell is a backward-compatible extension of the Bourne shell. Features that are valid only in the Korn shell are so indicated.

  • Command-line editing (using vi or emacs).

  • Access to previous commands (command history).

  • Integer arithmetic.

  • More ways to match patterns and substitute variables.

  • Arrays and arithmetic expressions.

  • Command name abbreviation (aliasing).

Previous: 3.5 Differing Features | UNIX in a Nutshell: System V Edition | Next: 4.2 Syntax
3.5 Differing Features | Book Index | 4.2 Syntax


[Chapter 4] 4.2 Syntax

Previous: 4.1 Overview of Features Chapter 4
The Bourne Shell and Korn Shell 		Next: 4.3 Variables

4.2 Syntax

This subsection describes the many symbols peculiar to the Bourne and Korn shell. The topics are arranged as follows:

  • Special files

  • Filename metacharacters

  • Quoting

  • Command forms

  • Redirection forms

  • Coprocesses (Korn shell only)

4.2.1 Special Files

/etc/profile | Executed automatically at login.
$HOME/.profile | Executed automatically at login.
/etc/passwd | Source of home directories for ~name abbreviations.
$ENV | Specifies the name of a file to read when a new Korn shell is created.

4.2.2 Filename Metacharacters

* | Match any string of zero or more characters.
? | Match any single character.
[abc...] | Match any one of the enclosed characters; a hyphen can be used to specify a range (e.g., a-z, A-Z, 0-9).
[!abc...] | Match any character not enclosed as above.

In the Korn shell:

?(pattern) | Match zero or one instance of pattern.
*(pattern) | Match zero or more instances of pattern.
+(pattern) | Match one or more instance of pattern.
@(pattern) | Match exactly one instance of pattern.
!(pattern) | Match any strings that don't contain pattern.
~ | HOME directory of the current user.
~name | HOME directory of user name.
~+ | Current working directory (PWD).
~- | Previous working directory (OLDPWD).

The pattern above can be a sequence of patterns separated by |, meaning that the match applies to any of the patterns. This extended syntax resembles that available to egrep and awk.

4.2.2.1 Examples

$ ls new*	List new and new.1.
$ cat ch?	Match ch9 but not ch10.
$ vi [D-R]*	Match files that begin with uppercase D through R.
$ cp !(Junk*|Temp*)*.c ..	Korn shell only.  Copy C source files
        except for Junk and Temp files.

4.2.3 Quoting

Quoting disables a character's special meaning and allows it to be used literally, as itself. The following characters have special meaning to the Bourne and Korn shells:

; | Command separator.
& | Background execution.
( ) | Command grouping.
| | Pipe.
> < & | Redirection symbols.
* ? [ ] ~ + - @ ! | Filename metacharacters.
" ' \ | Used in quoting other characters.
` | Command substitution.
$ | Variable substitution (or command substitution).
newline space tab | Word separators.

The characters below can be used for quoting:

" "

Everything between " and " is taken literally, except for the following characters that keep their special meaning:

$

Variable substitution will occur.

`

Command substitution will occur.

"

This marks the end of the double quote.

' '

Everything between ' and ' is taken literally except for another '.

\

The character following a \ is taken literally. Use within " " to escape ", $, and `. Often used to escape itself, spaces, or newlines.

4.2.3.1 Examples

$ echo 'Single quotes "protect" double quotes'
Single quotes "protect" double quotes
$ echo "Well, isn't that \"special\"?"
Well, isn't that "special"?
$ echo "You have `ls|wc -l` files in `pwd`"
You have      43 files in /home/bob
$ echo "The value of \$x is $x"
The value of $x is 100

4.2.4 Command Forms

cmd & | Execute cmd in background.
cmd1 ; cmd2 | Command sequence; execute multiple cmds on the same line.
(cmd1 ; cmd2) | Subshell; treat cmd1 and cmd2 as a command group.
cmd1 | cmd2 | Pipe; use output from cmd1 as input to cmd2.
cmd1 `cmd2` | Command substitution; use cmd2 output as arguments to cmd1.
cmd1 $(cmd2) | Korn-shell command substitution; nesting is allowed.
cmd1 && cmd2 | AND; execute cmd1 and then (if cmd1 succeeds) cmd2.
cmd1 || cmd2 | OR; execute either cmd1 or (if cmd1 fails) cmd2.
{ cmd1 ; cmd2 } | Execute commands in the current shell.

4.2.4.1 Examples

$ nroff file &	Format in the background.
$ cd; ls	Execute sequentially.
$ (date; who; pwd) > logfile	All output is redirected.
$ sort file | pr -3 | lp		Sort file, page output, then print.
$ vi `grep -l ifdef *.c`		Edit files found by grep.
$ egrep '(yes|no)' `cat list`	Specify a list of files to search.
$ egrep '(yes|no)' $(cat list)	Korn shell version of previous.
$ egrep '(yes|no)' $(<list)	Same, but faster.
$ grep XX file && lp file		Print file if it contains the pattern,
$ grep XX file || echo "XX not found"	otherwise, echo an error message.

4.2.5 Redirection Forms

File |  | Common | Typical
Descriptor | Name | Abbreviation | Default
0 | Standard Input | stdin | Keyboard
1 | Standard Output | stdout | Terminal
2 | Standard Error | stderr | Terminal

The usual input source or output destination can be changed as follows:

4.2.5.1 Simple Redirection

cmd > file | Send output of cmd to file (overwrite).
cmd >> file | Send output of cmd to file (append).
cmd < file | Take input for cmd from file.
cmd << text | Read standard input up to a line identical to text (text can be stored in a shell variable). Input is usually typed on the screen or in the shell program. Commands that typically use this syntax include cat, echo, ex, and sed. (If <<- is used, leading tabs are ignored when comparing input with end-of-input text marker.) This command form is sometimes called a "Here" document.

4.2.5.2 Redirection Using File Descriptors

cmd >&n | Send cmd output to file descriptor n.
cmd m>&n | Same, except that output that would normally go to file descriptor m is sent to file descriptor n instead.
cmd >&- | Close standard output.
cmd <&n | Take input for cmd from file descriptor n.
cmd m<&n | Same, except that input that would normally come from file descriptor m comes from file descriptor n instead.
cmd <&- | Close standard input.

4.2.5.3 Multiple Redirection

cmd 2>file | Send standard error to file; standard output remains the same (e.g., the screen).
cmd > file 2>&1 | Send both standard error and standard output to file.
(cmd > f1) 2>f2 | Send standard output to file f1; standard error to file f2.
cmd | tee files | Send output of cmd to standard output (usually the terminal) and to files. (See the example in Section 2 under tee.)

No space should appear between file descriptors and a redirection symbol; spacing is optional in the other cases.

4.2.5.4 Examples

$ cat part1 > book
$ cat part2 part3 >> book
$ mail tim < report
$ sed 's/^/XX /g' << END_ARCHIVE
> This is often how a shell archive is "wrapped",
> bundling text for distribution.  You would normally
> run sed from a shell program, not from the command line.
> END_ARCHIVE
XX This is often how a shell archive is "wrapped",
XX bundling text for distribution.  You would normally
XX run sed from a shell program, not from the command line.

To redirect standard output to standard error:

$ echo "Usage error:  see administrator" 1>&2

The following command will send output (files found) to filelist and send error messages (inaccessible files) to file no_access:

$ (find / -print > filelist) 2>no_access

4.2.6 Coprocesses

Coprocesses are a feature of the Korn shell only.

cmd1 | cmd2 |& | Coprocess; execute the pipeline in the background. The shell sets up a two-way pipe, allowing redirection of both standard input and standard output.
read -p var | Read coprocess input into variable var.
print -p string | Write string to the coprocess.
cmd <&p | Take input for cmd from the coprocess.
cmd >&p | Send output of cmd to the coprocess.

4.2.6.1 Examples

ed - memo |&	Start coprocess.
print -p /word/	Send ed command to coprocess.
read -p search	Read output of ed command into variable search.
print "$search"	Show the line on standard output.
A word to the wise.

Previous: 4.1 Overview of Features | UNIX in a Nutshell: System V Edition | Next: 4.3 Variables
4.1 Overview of Features | Book Index | 4.3 Variables


[Chapter 4] 4.3 Variables

Previous: 4.2 Syntax Chapter 4
The Bourne Shell and Korn Shell 		Next: 4.4 Arithmetic Expressions

4.3 Variables

This subsection describes the following:

  • Variable substitution

  • Built-in shell variables

  • Other shell variables

  • Arrays (Korn shell only)

4.3.1 Variable Substitution

No spaces should be used in the expressions below. The colon (:) is optional; if it's included, var must be non-null as well as set.

var=value ... | Set each variable var to a value.
${var} | Use value of var; braces are optional if var is separated.
${var:-value} | Use var if set; otherwise, use value.
${var:=value} | Use var if set; otherwise, use value and assign value to var.
${var:?value} | Use var if set; otherwise, print value and exit. If value isn't supplied, print the phrase "parameter null or not set."
${var:+value} | Use value if var is set; otherwise, use nothing.

In the Korn shell:

${#var} | Use the length of var.
${#*} | Use the number of positional parameters.
${#@} | Use the number of positional parameters.
${var#pattern} | Use value of var after removing pattern from the left. Remove the shortest matching piece.
${var##pattern} | Same as #pattern, but remove longest matching piece.
${var%pattern} | Use value of var after removing pattern from the right.
${var%%pattern} | Same as %pattern, but remove longest matching piece.

4.3.1.1 Examples

$ u=up d=down blank=	Assign values to three variables (last is null).
$ echo ${u}root		Braces are needed here.
uproot
$ echo ${u-$d}		Display value of u or d; since u is set, it is printed.
up
$ echo ${tmp-`date`}	If tmp is not set, the date command is executed.
Thu Feb  4 15:03:46 EST 1993
$ echo ${blank="no data"}	blank is set, so it is printed (a blank line).
$ echo ${blank:="no data"}	blank is set but null, so the string is printed
no data
$ echo $blank	blank now has a new value
no data

4.3.1.2 Korn Shell Example

tail='${PWD##*/}'	Take the current directory name and
    remove the longest character string ending with /.
    This removes the leading pathname and leaves the tail.

4.3.2 Built-in Shell Variables

Built-in variables are automatically set by the shell and are typically used inside shell scripts. Built-in variables can make use of the variable substitution patterns shown above. Note that the $ is not actually part of the variable name, although the variable is always referenced this way.

$# | Number of command-line arguments.
$- | Options currently in effect (arguments supplied to sh or to set).
$? | Exit value of last executed command.
$$ | Process number of current process.
$! | Process number of last background command.
$0 | First word; that is, command name.
$n | Individual arguments on command line (positional parameters). The Bourne shell allows only nine parameters to be referenced directly (n = 1-9); the Korn shell allows n to be greater than 9 if specified as ${n}.
$* | All arguments on command line ("$1 $2...").
"$@" | All arguments on command line, individually quoted ("$1" "$2" ...).

The Korn shell automatically sets these additional variables:

$_ | Temporary variable; initialized to pathname of script or program being executed. Later, stores the last argument of previous command. Also stores name of matching MAIL file during mail checks.
ERRNO | Error number of last system call that failed.
LINENO | Current line number within the script or function.
OLDPWD | Previous working directory (set by cd).
OPTARG | Name of last option processed by getopts.
OPTIND | Numerical index of OPTARG.
PPID | Process number of this shell's parent.
PWD | Current working directory (set by cd).
RANDOM[=n] | Generate a new random number with each reference; start with integer n, if given.
REPLY | Default reply used by select and read.
SECONDS[=n] | Number of seconds since the shell was started, or, if n is given, number of seconds + n since the shell started.

4.3.3 Other Shell Variables

The variables below are not automatically set by the shell. They are typically used in your .profile file, where you can define them to suit your needs. Variables can be assigned values by issuing commands of the form:

$ variable=value

The list below includes the type of value expected when defining these variables. Those that are specific to the Korn shell are marked as (K).

CDPATH=dirs | Directories searched by cd; allows shortcuts in changing directories; unset by default.
COLUMNS=n | (K) Screen's column width; used in line edit modes and select lists.
EDITOR=file | (K) Pathname of line edit mode to turn on (can end in emacs or vi); used when VISUAL is not set.
ENV=file | (K) Name of script that gets executed at startup; useful for storing alias and function definitions. For example, ENV=$HOME/.kshrc (like C shell's .cshrc).
FCEDIT=file | (K) Editor used by fc command (default is /bin/ed).
FPATH=dirs | (K) Directories to search for function definitions; undefined functions are set via typeset -fu; FPATH is searched when these functions are first referenced.
HISTFILE=file | (K) File in which to store command history (must be set before ksh is started); default is $HOME/.sh_history.
HISTSIZE=n | (K) Number of history commands available (must be set before ksh is started); default is 128.
HOME=dir | Home directory; set by login (from passwd file).
IFS='chars' | Internal field separators; default is space, tab, and newline.
LANG=dir | Directory to use for certain language-dependent programs.
LINES=n | (K) Screen's line length; used for select lists.
MAIL=file | Default file in which to receive mail; set by login.
MAILCHECK=n | Number of seconds between mail checks; default is 10 minutes.
MAILPATH=files | One or more files, delimited by a colon, in which to receive mail. Each file is printed. The Korn shell prompt is ? and the default message is You have mail in $_. The Bourne shell prompt is % and the default message is You have mail.
PATH=dir | One or more pathnames, delimited by a colon, in which to search for commands to execute; default is /usr/bin.
PS1=string | Primary prompt string; default is $.
PS2=string | Secondary prompt (used in multi-line commands); default is >.
PS3=string | (K) Prompt string in select loops; default is #?.
PS4=string | (K) Prompt string for execution trace (ksh -x or set -x); default is +.
SHACCT=file | "Shell account"; file in which to log executed shell scripts. Not in Korn shell.
SHELL=file | Name of shell environment (e.g., /bin/sh).
TERM=string | Terminal type.
TMOUT=n | (K) If no command is typed after n seconds, exit the shell.
VISUAL=path | (K) Same as EDITOR, but VISUAL is checked first.

4.3.4 Arrays

The Korn shell supports one-dimensional arrays of up to 1024 elements. The first element is numbered 0. An array name can be initialized as follows:

set -A name value0 value1 ...

where the specified values become elements of name. Declaring arrays is not required, however. Any valid reference to a subscripted variable can create an array.

When referencing arrays, you can use the ${ ... } syntax. This isn't needed when referencing arrays inside (( )) (the form of let that does automatic quoting). Note that [ and ] are typed literally (i.e., they don't stand for optional syntax).

${name[i]} | Use element i of array name. i can be any arithmetic expression as described under let. The expression must return a value between 0 and 1023.
${name[*]} | Use all elements of array name.
${name} | Use element 0 of array name.
${name[*]} | Use all elements in array name.
${#name[*]} | Use the number of elements in array name.
${#name[@]} | Use the number of elements in array name.

Previous: 4.2 Syntax | UNIX in a Nutshell: System V Edition | Next: 4.4 Arithmetic Expressions
4.2 Syntax | Book Index | 4.4 Arithmetic Expressions


[Chapter 4] 4.4 Arithmetic Expressions

Previous: 4.3 Variables Chapter 4
The Bourne Shell and Korn Shell 		Next: 4.5 Command History

4.4 Arithmetic Expressions

The Korn shell's let command performs integer arithmetic. The Korn shell provides a way to substitute integer values (for use as command arguments or in variables); base conversion is also possible:

$(( expr )) | Use the value of the enclosed arithmetic expression.
B#n | Interpret integer n in numeric base B. For example, 8#100 specifies the octal equivalent of decimal 64.

4.4.1 Operators

The Korn shell uses arithmetic operators from the C programming language; they are listed below in decreasing order of precedence:

- | Unary minus.
! ~ | Logical negation; binary inversion (one's complement).
* / % | Multiplication; division; modulus (remainder).
+ - | Addition; subtraction.
<< >> | Bitwise left shift; bitwise right shift.
<= >= | Less than or equal to; greater than or equal to.
< > | Less than; greater than.
== != | Equality; inequality (both evaluated left to right).
& | Bitwise AND.
^ | Bitwise exclusive OR.
| | Bitwise OR.
&& | Logical AND.
|| | Logical OR.
*= /= %= | Assignment.
= += -= |
<<= >>= |
&= ^= |= |

4.4.2 Examples

See the let command for more information and examples.

let "count=0" "i = i + 1"	Assign i and count.
let "num % 2"	Test for an even number.
(( percent >= 0 && percent <= 100 ))	Test the range of a value.

Previous: 4.3 Variables | UNIX in a Nutshell: System V Edition | Next: 4.5 Command History
4.3 Variables | Book Index | 4.5 Command History


[Chapter 4] 4.5 Command History

Previous: 4.4 Arithmetic Expressions Chapter 4
The Bourne Shell and Korn Shell 		Next: 4.6 Built-in Commands (Bourne and Korn Shell)

4.5 Command History

The Korn shell lets you display or modify previous commands. This is similar to the C shell's history mechanism. Commands in the history list can be modified using:

  • Line-edit mode

  • The fc command

4.5.1 Line-edit Mode

Line-edit mode lets you emulate many features of the vi or emacs editor. The history list is treated like a file. When the editor is invoked, you type editing keystrokes to move to the command line you want to execute. You can also change the line before executing it. When you're ready to issue the command, press RETURN.

Line-edit mode can be started in several ways. For example, these are equivalent:

$ VISUAL=vi
$ EDITOR=vi
$ set -o vi	Overrides value of VISUAL or EDITOR

Note that vi starts in input mode; to type a vi command, press ESCAPE first.

4.5.1.1 Common Editing Keystrokes

vi | emacs | Result
k | CTRL-p | Get previous command.
j | CTRL-n | Get next command.
/string | CTRL-r string | Get previous command containing string.
h | CTRL-b | Move back one character.
l | CTRL-f | Move forward one character.
b | ESC-b | Move back one word.
w | ESC-f | Move forward one word.
X | DEL | Delete previous character.
x | CTRL-d | Delete one character.
dw | ESC-d | Delete word forward.
db | ESC-h | Delete word back.
xp | CTRL-t | Transpose two characters.

4.5.2 The fc Command

Use fc -l to list history commands and fc -e to edit them. See the entry under built-in commands for more information.

4.5.2.1 Examples

$ history	List the last 16 commands.
$ fc -l 20 30	List commands 20 through 30.
$ fc -l -5	List the last five commands.
$ fc -l cat	List the last command beginning with cat.
$ fc -ln 5 > doit	Save command 5 to file doit.
$ fc -e vi 5 20	Edit commands 5 through 20 using vi.
$ fc -e emacs	Edit previous command using emacs.
$ r	Re-execute previous command.
$ r cat	Re-execute last cat command.
$ r doc=Doc	Substitute, then re-execute last command.
$ r chap=doc c	Re-execute last command that begins with c,
    but change string chap to doc.

Previous: 4.4 Arithmetic Expressions | UNIX in a Nutshell: System V Edition | Next: 4.6 Built-in Commands (Bourne and Korn Shell)
4.4 Arithmetic Expressions | Book Index | 4.6 Built-in Commands (Bourne and Korn Shell)


[Chapter 4] 4.6 Built-in Commands (Bourne and Korn Shell)

Previous: 4.5 Command History Chapter 4
The Bourne Shell and Korn Shell 		Next: 4.7 Job Control

4.6 Built-in Commands (Bourne and Korn Shell)

Examples to be entered as a command line are shown with the $ prompt. Otherwise, examples should be treated as code fragments that might be included in a shell script. For convenience, some of the reserved words used by multi-line commands are also included.

  • #
  • #!shell
  • :
  • .
  • [[ ]]
  • name
  • alias
  • autoload
  • bg
  • break
  • case
  • cd
  • continue
  • do
  • done
  • echo
  • esac
  • eval
  • exec
  • exit
  • export
  • false
  • fc
  • fg
  • fi
  • for
  • function
  • getopts
  • hash
  • hash
  • history
  • if
  • integer
  • jobs
  • kill
  • let
  • newgrp
  • nohup
  • print
  • pwd
  • r
  • read
  • read
  • readonly
  • return
  • select
  • set
  • shift
  • stop
  • suspend
  • test
  • time
  • times
  • trap
  • type
  • typeset
  • ulimit
  • umask
  • unalias
  • unset
  • until
  • wait
  • whence
  • while
  • filename

Previous: 4.5 Command History | UNIX in a Nutshell: System V Edition | Next: 4.7 Job Control
4.5 Command History | Book Index | 4.7 Job Control


[Chapter 4] 4.7 Job Control

Previous: 4.6 Built-in Commands (Bourne and Korn Shell) Chapter 4
The Bourne Shell and Korn Shell 		Next: 4.8 Invoking the Shell

4.7 Job Control

Job control lets you place foreground jobs in the background, bring background jobs to the foreground, or suspend (temporarily stop) running jobs. Job control is enabled by any of the following commands:

jsh -i	Bourne shell
ksh -m -i	Korn shell (same as next two)
set -m
set -o monitor

Many job control commands take jobID as an argument. This argument can be specified as follows:

%n

Job number n.

%s

Job whose command line starts with string s.

%?s

Job whose command line contains string s.

%%

Current job.

%+

Current job (same as above).

%-

Previous job.

The Bourne and Korn shells provide the following job control commands. For more information on these commands, see "Built-in Commands" earlier in this section.

bg

Put a job in the background.

fg

Put a job in the foreground.

jobs

List active jobs.

kill

Terminate a job.

stop

Suspend a background job.

stty tostop

Stop background jobs if they try to send output to the terminal.

suspend

Same as CTRL-Z.

wait

Wait for background jobs to finish.

CTRL-Z

Suspend a foreground job. Then use bg or fg. (Your terminal may use something other than CTRL-Z as the suspend character.)

Previous: 4.6 Built-in Commands (Bourne and Korn Shell) | UNIX in a Nutshell: System V Edition | Next: 4.8 Invoking the Shell
4.6 Built-in Commands (Bourne and Korn Shell) | Book Index | 4.8 Invoking the Shell


[Chapter 4] 4.8 Invoking the Shell

Previous: 4.7 Job Control Chapter 4
The Bourne Shell and Korn Shell 		Next: 4.9 Restricted Shells

4.8 Invoking the Shell

The command interpreter for the Bourne shell (sh) or the Korn shell (ksh) can be invoked as follows:

sh [options] [arguments]

ksh [options] [arguments]

ksh and sh can execute commands from a terminal (when -i is specified), from a file (when the first argument is an executable script), or from standard input (if no arguments remain or if -s is specified).

Arguments

Arguments are assigned in order to the positional parameters $1, $2, etc. If array assignment is in effect (-A or +A), arguments are assigned as array elements. If the first argument is an executable script, commands are read from it, and remaining arguments are assigned to $1, $2, etc.

Options

-c str

Read commands from string str.

-i

Create an interactive shell (prompt for input).

-p

Start up as a privileged user (i.e., don't process $HOME/.profile).

-r

Create a restricted shell (same as rksh or rsh).

-s

Read commands from standard input; output from built-in commands goes to file descriptor 1; all other shell output goes to file descriptor 2.

The remaining options to sh and ksh are listed under the set built-in command.

Previous: 4.7 Job Control | UNIX in a Nutshell: System V Edition | Next: 4.9 Restricted Shells
4.7 Job Control | Book Index | 4.9 Restricted Shells


[Chapter 4] 4.9 Restricted Shells

Previous: 4.8 Invoking the Shell Chapter 4
The Bourne Shell and Korn Shell 		Next: 5. The C Shell

4.9 Restricted Shells

Restricted shells can be invoked in any of the following ways:

rksh	Korn shell
ksh -r
set -r

rsh	Bourne Shell
set -r

Restricted shells can also be set up by supplying rksh and rsh in the shell field of /etc/passwd or by using them as the value for the SHELL variable.

Restricted shells act the same as their non-restricted counterparts, except that the following are prohibited:

  • Changing directory (i.e., using cd).

  • Setting the PATH variable. rksh also prohibits setting ENV and SHELL.

  • Specifying a / for command names or pathnames.

  • Redirecting output (i.e., using > and >>).

Shell scripts can still be run, since in that case the restricted shell will call ksh or sh to run the script.

Previous: 4.8 Invoking the Shell | UNIX in a Nutshell: System V Edition | Next: 5. The C Shell
4.8 Invoking the Shell | Book Index | 5. The C Shell


[Chapter 5] The C Shell

Previous: 4.9 Restricted Shells Chapter 5 Next: 5.2 Syntax

5. The C Shell

Contents:
Overview of Features
Syntax
Variables
Expressions
Command History csh shell
Built-in C Shell Commands
Job Control
Invoking the Shell

This section describes the C shell, so named because many of its programming constructs and symbols resemble those of the C programming language. The following topics are presented:

  • Overview of features

  • Syntax

  • Variables

  • Expressions

  • Command history

  • Built-in commands

  • Job control

  • Invoking the shell

5.1 Overview of Features

Features of the C shell include:

  • Input/output redirection

  • Wildcard characters (metacharacters) for filename abbreviation

  • Shell variables for customizing your environment

  • Integer arithmetic

  • Access to previous commands (command history)

  • Command name abbreviation (aliasing)

  • A built-in command set for writing shell programs

  • Job control

Previous: 4.9 Restricted Shells | UNIX in a Nutshell: System V Edition | Next: 5.2 Syntax
4.9 Restricted Shells | Book Index | 5.2 Syntax


[Chapter 5] 5.2 Syntax

Previous: 5.1 Overview of Features Chapter 5
The C Shell 		Next: 5.3 Variables

5.2 Syntax

This subsection describes the many symbols peculiar to the C shell. The topics are arranged as follows:

  • Special files

  • Filename metacharacters

  • Quoting

  • Command forms

  • Redirection forms

5.2.1 Special Files

~/.cshrc | Executed at each instance of shell.
~/.history | History list saved from previous login.
~/.login | Executed by login shell after .cshrc at login.
~/.logout | Executed by login shell at logout.
/etc/passwd | Source of home directories for ~name abbreviations.

5.2.2 Filename Metacharacters

* | Match any string of zero or more characters.
? | Match any single character.
[abc...] | Match any one of the enclosed characters; a hyphen can be used to specify a range (e.g., a-z, A-Z, 0-9).
{abc,xxx,...} | Expand each comma-separated string inside braces.
~ | Home directory for the current user.
~name | Home directory of user name.

5.2.2.1 Examples

% ls new*       Match new and new.1.
% cat ch?       Match ch9 but not ch10.
% vi [D-R]*     Match files that begin with uppercase D through R.
% ls {ch,app}?	 Expand, then match ch1, ch2, app1, app2.
% cd ~tom	 Change to tom's home directory.

5.2.3 Quoting

Quoting disables a character's special meaning and allows it to be used literally, as itself. The following characters have special meaning to the C shell:

; | Command separator.
& | Background execution.
( ) | Command grouping.
| | Pipe.
* ? [ ] ~ | Filename metacharacters.
{ } | String expansion characters. Usually don't require quoting.
> < & ! | Redirection symbols.
! ^ | History substitution, quick substitution.
" ' \ | Used in quoting other characters.
` | Command substitution.
$ | Variable substitution.
newline space tab | Word separators.

The characters below can be used for quoting:

" "

Everything between " and " is taken literally, except for the following characters that keep their special meaning:

$

Variable substitution will occur.

`

Command substitution will occur.

"

This marks the end of the double quote.

\

Escape next character.

!

The history character.

' ' | Everything between ' and ' is taken literally except for ! (history) and another ', and newline.
\ | The character following a \ is taken literally. Use within " " to escape ", $, and `. Often used to escape itself, spaces, or newlines. Always needed to escape a history character (usually !).

5.2.3.1 Examples

% echo 'Single quotes "protect" double quotes'
Single quotes "protect" double quotes
% echo "Well, isn't that \"special\"?"
Well, isn't that "special"?
% echo "You have `ls|wc -l` files in `pwd`"
You have 43 files in /home/bob
% echo "The value of \$x is $x"
The value of $x is 100

5.2.4 Command Forms

cmd & | Execute cmd in background.
cmd1 ; cmd2 | Command sequence; execute multiple cmds on the same line.
(cmd1 ; cmd2) | Subshell; treat cmd1 and cmd2 as a command group.
cmd1 | cmd2 | Pipe; use output from cmd1 as input to cmd2.
cmd1 `cmd2` | Command substitution; use cmd2 output as arguments to cmd1.
cmd1 && cmd2 | AND; execute cmd1 and then (if cmd1 succeeds) cmd2.
cmd1 || cmd2 | OR; execute either cmd1 or (if cmd1 fails) cmd2.

5.2.4.1 Examples

% nroff file &	Format in the background.
% cd; ls	Execute sequentially.
% (date; who; pwd) > logfile	All output is redirected.
% sort file | pr -3 | lp	Sort file, page output, then print.
% vi `grep -l ifdef *.c`	Edit files found by grep.
% egrep '(yes|no)' `cat list`	Specify a list of files to search.
% grep XX file && lp file	Print file if it contains the pattern,
% grep XX file || echo XX not found	otherwise, echo an error message.

5.2.5 Redirection Forms

File |  | Common | Typical
Descriptor | Name | Abbreviation | Default
0 | Standard Input | stdin | Keyboard
1 | Standard Output | stdout | Terminal
2 | Standard Error | stderr | Terminal

The usual input source or output destination can be changed as follows:

5.2.5.1 Simple Redirection

cmd > file | Send output of cmd to file (overwrite).
cmd >! file | Same as above, even if noclobber is set.
cmd >> file | Send output of cmd to file (append).
cmd >>! file | Same as above, but create file even if noclobber is set.
cmd < file | Take input for cmd from file.
cmd << text | Read standard input up to a line identical to text (text can be stored in a shell variable).Input is usually typed on the screen or in the shell program. Commands that typically use this syntax include cat, echo, ex, and sed. If text is enclosed in quotes, standard input will not undergo variable substitution, command substitution, etc.

5.2.5.2 Multiple Redirection

cmd >& file | Send both standard output and standard error to file.
cmd >&! file | Same as above, even if noclobber is set.
cmd >>& file | Append standard output and standard error to end of file.
cmd >>&! file | Same as above, but create file even if noclobber is set.
cmd1 |& cmd2 | Pipe standard error together with standard output.
(cmd > f1) >& f2 | Send standard output to file f1; standard error to file f2.
cmd | tee files | Send output of cmd to standard output (usually the terminal) and to files. (See the example in Section 2 under tee.)

5.2.5.3 Examples

% cat part1 > book
% cat part2 part3 >> book
% mail tim < report
% cc calc.c >& error_out
% cc newcalc.c >&! error_out
% grep UNIX ch* |& pr
% (find / -print > filelist) >& no_access

% sed 's/^/XX /g' << "END_ARCHIVE"
This is often how a shell archive is "wrapped",
bundling text for distribution.  You would normally
run sed from a shell program, not from the command line.
"END_ARCHIVE"
XX This is often how a shell archive is "wrapped",
XX bundling text for distribution.  You would normally
XX run sed from a shell program, not from the command line.

Previous: 5.1 Overview of Features | UNIX in a Nutshell: System V Edition | Next: 5.3 Variables
5.1 Overview of Features | Book Index | 5.3 Variables


[Chapter 5] 5.3 Variables

Previous: 5.2 Syntax Chapter 5
The C Shell 		Next: 5.4 Expressions

5.3 Variables

This subsection describes the following:

  • Variable substitution

  • Variable modifiers

  • Predefined shell variables

  • Example .cshrc file

  • Environment variables

5.3.1 Variable Substitution

In the following substitutions, braces ({}) are optional, except when needed to separate a variable name from following characters that would otherwise be a part of it.

${var} | The value of variable var.
${var[i]} | Select word or words in position i of var. i can be a single number, a range m-n, a range -n (missing m implies 1), a range m- (missing n implies all remaining words), or * (select all words). i can also be a variable that expands to one of these values.
${#var} | The number of words in var.
${#argv} | The number of arguments.
$0 | Name of the program.
${#argv[n]} | Individual arguments on command line (positional parameters). n = 1-9.
${n} | Same as ${argv[n]}.
${#argv[*]} | All arguments on command line.
$* | Same as $argv[*].
$argv[$#argv] | The last argument.
${?var} | Return 1 if var is set; 0 if var is not set.
$$ | Process number of current shell; useful as part of a filename for creating temporary files with unique names.
$?0 | Return 1 if input filename is known; 0 if not.
$< | Read a line from standard input.

5.3.1.1 Examples

Sort the third through last arguments (files) and save the output in a unique temporary file:

sort $argv[3-] > tmp.$$

Process .cshrc commands only if the shell is interactive (i.e., the prompt variable must be set).

if ($?prompt) then
   set commands,
   alias commands,
   etc.
endif

5.3.2 Variable Modifiers

Except for $?var, $$, $?0, and $<, the variable substitutions above may be followed by one of these modifiers. When braces are used, the modifier goes inside them.

:r

Return the variable's root.

:e

Return the variable's extension.

:h

Return the variable's header.

:t

Return the variable's tail.

:gr

Return all roots.

:ge

Return all extensions.

:gh

Return all headers.

:gt

Return all tails.

:q

Quote a wordlist variable, keeping the items separate. Useful when the variable contains filename metacharacters that should not be expanded.

:x

Quote a pattern, expanding it into a wordlist.

5.3.2.1 Examples Using Pathname Modifiers

The table below shows the use of pathname modifiers on the following variable:

aa=(/progs/num.c /book/chap.ps)

Variable Portion | Specification | Output Result
Normal Variable | echo $aa | /progs/num.c /book/chap.ps
Second Root | echo $aa[2]:r | /book/chap
Second Header | echo $aa[2]:h | /book
Second Tail | echo $aa[2]:t | chap.ps
Second Extension | echo $aa[2]:e | ps
Root | echo $aa:r | /progs/num /book/chap.ps
Global Root | echo $aa:gr | /progs/num /book/chap
Header | echo $aa:h | /progs /book/chap.ps
Global Header | echo $aa:gh | /progs /book
Tail | echo $aa:t | num.c /book/chap.ps
Global Tail | echo $aa:gt | num.c chap.ps
Extension | echo $aa:e | c /book/chap.ps
Global Extension | echo $aa:ge | c ps

5.3.2.2 Examples Using Quoting Modifiers

% set a="[a-z]*" A="[A-Z]*"
% echo "$a" "$A"
[a-z]* [A-Z]*

% echo $a $A
at cc m4 Book Doc

% echo $a:x $A
[a-z]* Book Doc

% set d=($a:q $A:q)
% echo $d
at cc m4 Book Doc

% echo $d:q
[a-z]* [A-Z]*

% echo $d[1] +++ $d[2]
at cc m4 +++ Book Doc

% echo $d[1]:q
[a-z]*

5.3.3 Predefined Shell Variables

Variables can be set in one of two ways, by assigning a value:

set var=value

or by simply turning them on:

set var

In the table below, variables that accept values are shown with the equal sign followed by the type of value they accept; the value is then described. (Note, however, that variables such as argv, cwd, or status are never explicitly assigned.) For variables that are turned on or off, the table describes what they do when set. The C shell automatically sets the variables argv, cwd, home, path, prompt, shell, status, term, and user.

argv=(args) | List of arguments passed to current command; default is ().
cdpath=(dirs) | List of alternate directories to search when locating arguments for cd, popd, or pushd.
cwd=dir | Full pathname of current directory.
echo | Re-display each command line before execution; same as csh -x command.
fignore=(chars) | List of filename suffixes to ignore during filename completion (see filec).
filec | If set, a filename that is partially-typed on the command line can be expanded to its full name when ESC is pressed. If more than one filename would match, type EOF to list possible completions.
hardpaths | Tell dirs to display the actual pathname of any directory that is a symbolic link.
histchars=ab | A two-character string that sets the characters to use in history-substitution and quick-substitution (default is !^).
history=n | Number of commands to save in history list.
home=dir | Home directory of user, initialized from HOME. The ~ character is shorthand for this value.
ignoreeof | Ignore an end-of-file (EOF) from terminals; prevents accidental logout.
mail=(n file) | One or more files checked for new mail every 5 minutes or (if n is supplied) every n seconds.
nobeep | Don't ring bell for ambiguous file completion (see filec).
noclobber | Don't redirect output to an existing file; prevents accidental destruction of files.
noglob | Turn off filename expansion; useful in shell scripts.
nonomatch | Treat filename metacharacters as literal characters; e.g., vi ch* creates new file ch* instead of printing ``No match."
notify | Notify user of completed jobs right away, instead of waiting for the next prompt.
path=(dirs) | List of pathnames in which to search for commands to execute. Initialized from PATH; default is ( . /usr/ucb /usr/bin ).
prompt='str' | String that prompts for interactive input; default is %.
savehist=n | Number of history commands to save in ~/.history upon logout; they can be accessed at the next login.
shell=file | Pathname of the shell program currently in use; default is /bin/csh.
status=n | Exit status of last command. Built-in commands return 0 (success) or 1 (failure).
term=ID | Name of terminal type, initialized to /etc/ttytype; same as TERM.
time='n %c' | If command execution takes more than n CPU seconds, report user time, system time, elapsed time, and CPU percentage. Supply optional %c flags to show other data.
user=name | Login name of user, initialized from USER.
verbose | Display a command after history substitution; same as the command csh -v.

5.3.4 Example .cshrc File

# PREDEFINED VARIABLES
set path=(~ ~/bin /usr/ucb /bin /usr/bin . )
set mail=(/usr/mail/tom)

if ($?prompt) then           # settings for interactive use
  set echo
  set filec
  set noclobber ignoreeof

  set cdpath=(/usr/lib /usr/spool/uucp)
# Now I can type cd macros
# instead of cd /usr/lib/macros

  set fignore=.o             # ignore object files for filec
  set history=100 savehist=25
  set prompt='tom \!% '      # includes history number
  set time=3

# MY VARIABLES

  set man1="/usr/man/man1"     # lets me do   cd $man1, ls $man1
  set a="[a-z]*"               # lets me do   vi $a
  set A="[A-Z]*"               # or           grep string $A

# ALIASES

  alias c "clear; dirs"        # use quotes to protect ; or |
  alias h "history|more"
  alias j jobs -l
  alias ls ls -sFC             # redefine ls command
  alias del 'mv \!* ~/tmp_dir' # a safe alternative to rm
endif

5.3.5 Environment Variables

The C shell maintains a set of environment variables, which are distinct from shell variables and aren't really part of the C shell. Shell variables are meaningful only within the current shell, but environment variables are automatically exported, making them available globally. For example, C shell variables are accessible only to a particular script in which they're defined, whereas environment variables can be used by any shell scripts, mail utilities, or editors you might invoke.

Environment variables are assigned as follows:

setenv VAR value

By convention, environment variable names are all uppercase. You can create your own environment variables, or you can use the predefined environment variables below.

These environment variables have a corresponding C shell variable. When either one changes, the value is copied to the other:

HOME

Home directory; same as home.

PATH

Search path for commands; same as path.

TERM

Terminal type; same as term.

USER

User name; same as user.

Other environment variables include the following:

EXINIT

A string of ex commands similar to those found in the startup .exrc file (e.g., set ai). Used by vi and ex.

LOGNAME

Another name for the USER variable.

MAIL

The file that holds mail. Used by mail programs. This is not the same as the C shell mail variable, which only checks for new mail.

PWD

The current directory; the value is copied from cwd.

SHELL

Undefined by default; once initialized to shell, the two are identical.

TERMCAP

The file that holds the cursor-positioning codes for your terminal type. Default is /etc/termcap.

Previous: 5.2 Syntax | UNIX in a Nutshell: System V Edition | Next: 5.4 Expressions
5.2 Syntax | Book Index | 5.4 Expressions


[Chapter 5] 5.4 Expressions

Previous: 5.3 Variables Chapter 5
The C Shell 		Next: 5.5 Command History csh shell

5.4 Expressions

Expressions are used in @, if, and while statements to perform arithmetic, string comparisons, file testing, etc. exit and set can also specify expressions. Expressions are formed by combining variables and constants with operators that resemble those in the C programming language. Operator precedence is the same as in C but can be remembered as follows:

  1. * / %

  2. + -

Group all other expressions inside ( )'s. Parentheses are required if the expression contains <, >, &, or |.

5.4.1 Operators

Operators can be one of the following types:

5.4.1.1 Assignment Operators

= | Assign value.
+= -= | Reassign after addition/subtraction.
*= /= %= | Reassign after multiplication/division/remainder.
&= ^= |= | Reassign after bitwise AND/XOR/OR.
++ | Increment
- | Decrement.

5.4.1.2 Arithmetic Operators

* / % | Multiplication; integer division; modulus (remainder).
+ - | Addition; subtraction.

5.4.1.3 Bitwise and Logical Operators

~ | Binary inversion (one's complement).
! | Logical negation.
< >> | Bitwise left shift; bitwise right shift.
& | Bitwise AND.
^ | Bitwise exclusive OR.
| | Bitwise OR.
&& | Logical AND.
|| | Logical OR.
{ command } | Return 1 if command is successful; 0 otherwise. Note that this is the opposite of command's normal return code. The $status variable may be more practical.

5.4.1.4 Comparison Operators

== != | Equality; inequality.
<= >= | Less than or equal to; greater than or equal to.
< > | Less than; greater than.
=~ | String on left matches a filename pattern containing *, ?, or [...].
!~ | String on left does not match a filename pattern containing *, ?, or [...].

5.4.1.5 File Inquiry Operators

Command substitution and filename expansion are performed on file before the test is performed.

-d file | The file is a directory.
-e file | The file exists.
-f file | The file is a plain file.
-o file | The user owns the file.
-r file | The user has read permission.
-w file | The user has write permission.
-x file | The user has execute permission.
-z file | The file has zero size.
! | Reverse the sense of any inquiry above.

5.4.2 Examples

The following examples show @ commands and assume n = 4:

Expression | Value of $x
@ x = ($n > 10 || $n < 5) | 1
@ x = ($n >= 0 && $n < 3) | 0
@ x = ($n << 2) | 16
@ x = ($n >> 2) | 1
@ x = $n % 2 | 0
@ x = $n % 3 | 1

The following examples show the first line of if or while statements:

Expression | Meaning
while ($#argv != 0) | While there are arguments ...
if ($today[1] == "Fri") | If the first word is "Fri"...
if ($file !~ *.[zZ]) | If the file doesn't end with .z or .Z ...
if ($argv[1] =~ chap?) | If the first argument is chap followed by a single character...
if (-f $argv[1]) | If the first argument is a plain file...
if (! -d $tmpdir) | If tmpdir is not a directory...

Previous: 5.3 Variables | UNIX in a Nutshell: System V Edition | Next: 5.5 Command History csh shell
5.3 Variables | Book Index | 5.5 Command History csh shell


[Chapter 5] 5.5 Command History csh shell

Previous: 5.4 Expressions Chapter 5
The C Shell 		Next: 5.6 Built-in C Shell Commands

5.5 Command History csh shell

Previously executed commands are stored in a history list. The C shell lets you access this list so you can verify commands, repeat them, or execute modified versions of them. The history built-in command displays the history list; the predefined variables histchars, history, and savehist also affect the history mechanism. Accessing the history list involves three things:

  • Making command substitutions (using ! and ^ ).

  • Making argument substitutions (specific words within a command).

  • Using modifiers to extract or replace parts of a command or word.

5.5.1 Command Substitution

! | Begin a history substitution.
!! | Previous command.
!N | Command number N in history list.
!-N | Nth command back from current command.
!string | Most recent command that starts with string.
!?string? | Most recent command that contains string.
!?string?% | Most recent command argument that contains string.
!$ | Last argument of previous command.
!!string | Previous command, then append string.
!N string | Command N, then append string.
!{s1}s2 | Most recent command starting with string s1, then append string s2.
^old^new^ | Quick substitution; change string old to new in previous command; execute modified command.

5.5.2 Command Substitution Examples

The following command is assumed:

%3 vi cprogs/01.c ch002 ch03

Event | Command | Command
Number | Typed | Executed
4 | ^00^0 | vi cprogs/01.c ch02 ch03
5 | nroff !* | nroff cprogs/01.c ch02 ch03
6 | nroff !$ | nroff ch03
7 | !vi | vi cprogs/01.c ch02 ch03
8 | !6 | nroff ch03
Event | Command | Command
Number | Typed | Executed
9 | !?01 | vi cprogs/01.c ch02 ch03
10 | !{nr}.new | nroff ch03.new
11 | !!|lp | nroff ch03.new | lp
12 | more !?pr?% | more cprogs/01.c

5.5.3 Word Substitution

Colons may precede any word specifier. After an event number, colons are optional unless shown below:

:0 | Command name.
:n | Argument number n.
^ | First argument.
$ | Last argument.
:n-m | Arguments n through m.
-m | Words 0 through m; same as :0-m.
:n- | Arguments n through next-to-last.
:n* | Arguments n through last; same as n-$.
* | All arguments; same as ^-$ or 1-$.
# | Current command line up to this point; fairly useless.

5.5.4 Word Substitution Examples

The following command is assumed:

%13 cat ch01 ch02 ch03 biblio back

Event | Command | Command
Number | Typed | Executed
14 | ls !13^ | ls ch01
15 | sort !13:* | sort ch01 ch02 ch03 biblio back
16 | lp !cat:3* | more ch03 biblio back
17 | !cat:0-3 | cat ch01 ch02 ch03
18 | vi !-5:4 | vi biblio

5.5.5 History Modifiers

Command and word substitutions can be modified by one or more of the following:

5.5.5.1 Printing, Substitution, and Quoting

:p | Display command but don't execute.
:s/old/new | Substitute string new for old, first instance only.
:gs/old/new | Substitute string new for old, all instances.
:& | Repeat previous substitution (:s or ^ command), first instance only.
:g& | Repeat previous substitution, all instances.
:q | Quote a wordlist.
:x | Quote separate words.

5.5.5.2 Truncation

:r | Extract the first available pathname root.
:gr | Extract all pathname roots.
:e | Extract the first available pathname extension.
:ge | Extract all pathname extensions.
:h | Extract the first available pathname header.
:gh | Extract all pathname headers.
:t | Extract the first available pathname tail.
:gt | Extract all pathname tails.

5.5.6 History Modifier Examples

From above, command number 17 is:

%17 cat ch01 ch02 ch03

Event | Command | Command
Number | Typed | Executed
19 | !17:s/ch/CH/ | cat CH01 ch02 ch03
20 | !:g& | cat CH01 CH02 CH03
21 | !more:p | more cprogs/01.c (displayed only)
22 | cd !$:h | cd cprogs
23 | vi !mo:$:t | vi 01.c
24 | grep stdio !$ | grep stdio 01.c
25 | ^stdio^include stdio^:q | grep "include stdio" 01.c
26 | nroff !21:t:p | nroff 01.c (is that want I wanted?)
27 | !! | nroff 01.c (execute it)

Previous: 5.4 Expressions | UNIX in a Nutshell: System V Edition | Next: 5.6 Built-in C Shell Commands
5.4 Expressions | Book Index | 5.6 Built-in C Shell Commands


[Chapter 5] 5.6 Built-in C Shell Commands

Previous: 5.5 Command History csh shell Chapter 5
The C Shell 		Next: 5.7 Job Control

5.6 Built-in C Shell Commands

  • #
  • #!
  • :
  • alias
  • bg
  • break
  • breaksw
  • case
  • cd
  • chdir
  • continue
  • default
  • dirs
  • echo
  • end
  • endif
  • eval
  • exec
  • exit
  • fg
  • foreach
  • glob
  • goto
  • hashstat
  • history
  • if
  • jobs
  • kill
  • limit
  • login
  • logout
  • nice
  • nohup
  • notify
  • onintr
  • popd
  • pushd
  • rehash
  • repeat
  • set
  • setenv
  • shift
  • source
  • stop
  • suspend
  • switch
  • time
  • umask
  • unalias
  • unhash
  • unlimit
  • unset
  • unsetenv
  • wait
  • while
  • @

Previous: 5.5 Command History csh shell | UNIX in a Nutshell: System V Edition | Next: 5.7 Job Control
5.5 Command History csh shell | Book Index | 5.7 Job Control


[Chapter 5] 5.7 Job Control

Previous: 5.6 Built-in C Shell Commands Chapter 5
The C Shell 		Next: 5.8 Invoking the Shell

5.7 Job Control

Job control lets you place foreground jobs in the background, bring background jobs to the foreground, or suspend (temporarily stop) running jobs. The C shell provides the following commands for job control. For more information on these commands, see "Built-in Commands" earlier in this section.

bg

Put a job in the background.

fg

Put a job in the foreground.

jobs

List active jobs.

kill

Terminate a job.

notify

Notify when a background job finishes.

stop

Suspend a background job.

CTRL-Z

Suspend a foreground job.

Many job control commands take jobID as an argument. This argument can be specified as follows:

%n

Job number n.

%s

Job whose command line starts with string s.

%?s

Job whose command line contains string s.

%%

Current job.

%

Current job (same as above).

%+

Current job (same as above).

%-

Previous job.

Previous: 5.6 Built-in C Shell Commands | UNIX in a Nutshell: System V Edition | Next: 5.8 Invoking the Shell
5.6 Built-in C Shell Commands | Book Index | 5.8 Invoking the Shell


[Chapter 5] 5.8 Invoking the Shell

Previous: 5.7 Job Control Chapter 5
The C Shell 		Next: 6. Pattern Matching

5.8 Invoking the Shell

The C-shell command interpreter can be invoked as follows:

csh [options] [arguments]

csh uses syntax resembling C and executes commands from a terminal or a file. Options -n, -v, and -x are useful when debugging scripts.

Options

-b

Allow the remaining command-line options to be interpreted as options to a specified command, rather than as options to csh itself.

-c

Execute commands located in first filename argument.

-e

Exit if a command produces errors.

-f

Fast start up; start csh without executing .cshrc or .login.

-i

Invoke interactive shell (prompt for input).

-n

Parse commands but do not execute.

-s

Read commands from the standard input.

-t

Exit after executing one command.

-v

Display commands before executing them; expand history substitutions but don't expand other substitutions (e.g., filename, variable, and command). Same as setting verbose.

-V

Same as -v, but also display .cshrc.

-x

Display commands before executing them, but expand all substitutions. Same as setting echo. -x is often combined with -v.

-X

Same as -x, but also display .cshrc.

Previous: 5.7 Job Control | UNIX in a Nutshell: System V Edition | Next: 6. Pattern Matching
5.7 Job Control | Book Index | 6. Pattern Matching


[Chapter 6] Pattern Matching

Previous: 5.8 Invoking the Shell Chapter 6 Next: 6.2 Metacharacters, Listed by UNIX Program

6. Pattern Matching

Contents:
Filenames Versus Patterns
Metacharacters, Listed by UNIX Program
Metacharacters
Examples of Searching

A number of UNIX text-editing utilities let you search for, and in some cases change, text patterns rather than fixed strings. These utilities include the editing programs ed, ex, vi, and sed, the awk scripting language, and the commands grep and egrep. Text patterns (also called regular expressions) contain normal characters mixed with special characters (also called metacharacters).

This section presents the following topics:

  • Filenames versus patterns

  • List of metacharacters available to each program

  • Description of metacharacters

  • Examples

6.1 Filenames Versus Patterns

Metacharacters used in pattern matching are different from metacharacters used for filename expansion (see Sections 4 and 5). When you issue a command on the command line, special characters are seen first by the shell, then by the program; therefore, unquoted metacharacters are interpreted by the shell for filename expansion. The command:

$ grep [A-Z]* chap[12]

could, for example, be interpreted by the shell as:

$ grep Array.c Bug.c Comp.c chap1 chap2

and would then try to find the pattern Array.c in files Bug.c, Comp.c, chap1, and chap2. To bypass the shell and pass the special characters to grep, use quotes:

$ grep "[A-Z]*" chap[12]

Double quotes suffice in most cases, but single quotes are the safest bet.

(Note also that in pattern matching, ? matches zero or one instance of a regular expression; in filename expansion, ? matches a single character.)

Previous: 5.8 Invoking the Shell | UNIX in a Nutshell: System V Edition | Next: 6.2 Metacharacters, Listed by UNIX Program
5.8 Invoking the Shell | Book Index | 6.2 Metacharacters, Listed by UNIX Program


[Chapter 6] 6.2 Metacharacters, Listed by UNIX Program

Previous: 6.1 Filenames Versus Patterns Chapter 6
Pattern Matching 		Next: 6.3 Metacharacters

6.2 Metacharacters, Listed by UNIX Program

Some metacharacters are valid for one program but not for another. Those that are available to a UNIX program are marked by a bullet ( ·) in the table below. Full descriptions are provided after the table.

Symbol | ed | ex | vi | sed | awk | grep | egrep | Action
. | · | · | · | · | · | · | · | Match any character.
* | · | · | · | · | · | · | · | Match zero or more preceding.
^ | · | · | · | · | · | · | · | Match beginning of line.
$ | · | · | · | · | · | · | · | Match end of line.
\ | · | · | · | · | · | · | · | Escape character following.
[ ] | · | · | · | · | · | · | · | Match one from a set.
\( \) | · | · |  | · |  |  |  | Store pattern for later replay.
\{ \} | · |  |  | · |  | · |  | Match a range of instances.
\< \> | · | · | · |  |  |  |  | Match word's beginning or end.
+ |  |  |  |  | · |  | · | Match one or more preceding.
? |  |  |  |  | · |  | · | Match zero or one preceding.
| |  |  |  |  | · |  | · | Separate choices to match.
( ) |  |  |  |  | · |  | · | Group expressions to match.

In ed, ex, and sed, note that you specify both a search pattern (on the left) and a replacement pattern (on the right). The metacharacters above are meaningful only in a search pattern.

In ed, ex, and sed, the following additional metacharacters are valid only in a replacement pattern:

Symbol | ex | sed | ed | Action
\ | · | · | · | Escape character following.
\n | · | · | · | Reuse pattern stored in \( \).
& | · | · |  | Reuse previous search pattern.
~ | · |  |  | Reuse previous replacement pattern.
\u \U | · |  |  | Change character(s) to uppercase.
\l \L | · |  |  | Change character(s) to lowercase.
\E | · |  |  | Turn off previous \U or \L.
\e | · |  |  | Turn off previous \u or \l.

Previous: 6.1 Filenames Versus Patterns | UNIX in a Nutshell: System V Edition | Next: 6.3 Metacharacters
6.1 Filenames Versus Patterns | Book Index | 6.3 Metacharacters


[Chapter 6] 6.3 Metacharacters

Previous: 6.2 Metacharacters, Listed by UNIX Program Chapter 6
Pattern Matching 		Next: 6.4 Examples of Searching

6.3 Metacharacters

The characters below have special meaning only in search patterns:

. | Match any single character except newline.
* | Match any number (or none) of the single character that immediately precedes it. The preceding character can also be a regular expression. E.g., since . (dot) means any character, .* means "match any number of any character."
^ | Match the following regular expression at the beginning of the line.
$ | Match the preceding regular expression at the end of the line.
[ ] | Match any one of the enclosed characters.
 | A hyphen (-) indicates a range of consecutive characters. A circumflex (^) as the first character in the brackets reverses the sense: it matches any one character not in the list. A hyphen or close bracket (]) as the first character is treated as a member of the list. All other metacharacters are treated as members of the list.
\{n,m\} | Match a range of occurrences of the single character that immediately precedes it. The preceding character can also be a regular expression. \{n\} matches exactly n occurrences, \{n \} matches at least n occurrences, and \{n,m\} matches any number of occurrences between n and m. n and m must be between 0 and 256, inclusive.
\ | Turn off the special meaning of the character that follows.
\( \) | Save the pattern enclosed between \( and \) into a special holding space. Up to nine patterns can be saved on a single line. They can be "replayed" in substitutions by the escape sequences \1 to \9.
\< \> | Match characters at beginning (\<) or end (\>) of a word.
+ | Match one or more instances of preceding regular expression.
? | Match zero or one instances of preceding regular expression.
| | Match the regular expression specified before or after.
( ) | Apply a match to the enclosed group of regular expressions.

The characters below have special meaning only in replacement patterns.

\ | Turn off the special meaning of the character that follows.
\n | Restore the nth pattern previously saved by \( and \). n is a number from 1 t 9, with 1 starting on the left.
& | Reuse the search pattern as part of the replacement pattern.
~ | Reuse the previous replacement pattern in the current replacement pattern.
\u | Convert first character of replacement pattern to uppercase.
\U | Convert replacement pattern to uppercase.
\l | Convert first character of replacement pattern to lowercase.
\L | Convert replacement pattern to lowercase.

Previous: 6.2 Metacharacters, Listed by UNIX Program | UNIX in a Nutshell: System V Edition | Next: 6.4 Examples of Searching
6.2 Metacharacters, Listed by UNIX Program | Book Index | 6.4 Examples of Searching


[Chapter 6] 6.4 Examples of Searching

Previous: 6.3 Metacharacters Chapter 6
Pattern Matching 		Next: 7. The Emacs Editor

6.4 Examples of Searching

When used with grep or egrep, regular expressions are surrounded by quotes. (If the pattern contains a $, you must use single quotes; e.g., 'pattern'.) When used with ed, ex, sed, and awk, regular expressions are usually surrounded by / (although any delimiter works). Here are some example patterns:

Pattern | What does it match?
bag | The string bag.
^bag | bag at beginning of line.
bag$ | bag at end of line.
^bag$ | bag as the only word on line.
[Bb]ag | Bag or bag.
b[aeiou]g | Second letter is a vowel.
b[^aeiou]g | Second letter is a consonant (or uppercase or symbol).
b.g | Second letter is any character.
^...$ | Any line containing exactly three characters.
^\. | Any line that begins with a dot.
^\.[a-z][a-z] | Same, followed by two lowercase letters (e.g., troff requests).
^\.[a-z]\{2\} | Same as previous, grep or sed only.
^[^.] | Any line that doesn't begin with a dot.
bugs* | bug, bugs, bugss, etc.
"word" | A word in quotes.
"*word"* | A word, with or without quotes.
[A-Z][A-Z]* | One or more uppercase letters.
[A-Z]+ | Same, egrep or awk only.
[A-Z].* | An uppercase letter, followed by zero or more characters.
[A-Z]* | Zero or more uppercase letters.
[a-zA-Z] | Any letter.
[^0-9A-Za-z] | Any symbol (not a letter or a number).
egrep or awk pattern | What does it match?
[567] | One of the numbers 5, 6, or 7.
five|six|seven | One of the words five, six, or seven.
80[23]?86 | 8086, 80286, or 80386
compan(y|ies) | company or companies
ex or vi pattern | What does it match?
\<the | Words like theater or the.
the\> | Words like breathe or the.
\<the\> | The word the.
sed or grep pattern | What does it match?
0\{5,\} | Five or more zeros in a row.
[0-9]\{3\}-[0-9]\{2\}-[0-9]\{4\} | Social security number (nnn-nn-nnnn).

6.4.1 Examples of Searching and Replacing

The following examples show the metacharacters available to sed or ex. Note that ex commands begin with a colon. A space is marked by a [image]; a tab is marked by tab.

Command | Result
s/.*/( & )/ | Redo the entire line, but add parentheses.
s/.*/mv & &.old/ | Change a wordlist (one word per line) into mv commands.
/^$/d | Delete blank lines.
:g/^$/d | Same as previous, in ex editor.
/^[ [image] tab]*$/d | Delete blank lines, plus lines containing spaces or tabs.
:g/^[ [image] tab]*$/d | Same as previous, in ex editor.
s/ [image] [image] */ [image] /g | Turn one or more spaces into one space.
%s/ [image] [image] */ [image] /g | Same as previous, in ex editor.
:s/[0-9]/Item &:/ | Turn a number into an item label (on the current line).
:s | Repeat the substitution on the first occurrence.
:& | Same as previous.
:sg | Same, but for all occurrences on the line.
:&g | Same as previous.
:%&g | Repeat the substitution globally.
:.,$s/Fortran/\U&/g | Change word to uppercase, on current line to last line.
:%s/.*/\L&/ | Lowercase entire file.
:s/\<./\u&/g | Uppercase first letter of each word on current line. (Useful for titles.)
:%s/yes/No/g | Globally change a word to No.
:%s/Yes/~/g | Globally change a different word to No (previous replacement).

Finally, some sed examples for transposing words. A simple transposition of two words might look like this:

s/die or do/do or die/	Transpose words.

The real trick is to use hold buffers to transpose variable patterns. For example:

s/\([Dd]ie\) or \([Dd]o\)/\2 or \1/	Transpose, using hold buffers.

Previous: 6.3 Metacharacters | UNIX in a Nutshell: System V Edition | Next: 7. The Emacs Editor
6.3 Metacharacters | Book Index | 7. The Emacs Editor


[Chapter 7] The Emacs Editor

Previous: 6.4 Examples of Searching Chapter 7 Next: 7.2 Summary of Commands by Group

7. The Emacs Editor

Contents:
Introduction
Summary of Commands by Group
Summary of Commands by Key
Summary of Commands by Name

This section presents the following topics:

  • Introduction

  • Summary of emacs commands by group

  • Summary of emacs commands by key

  • Summary of emacs commands by name

7.1 Introduction

Although emacs is not part of SVR4 or Solaris 2.0, this text editor is found on many UNIX systems because it is a popular alternative to vi. Many versions are available. This book documents GNU emacs, which is available from the Free Software Foundation in Cambridge, Mass. For more information about emacs, see the Nutshell Handbook Learning GNU Emacs.

To start an emacs editing session, type:

emacs [file]

On some systems, GNU emacs is invoked by typing "gmacs" instead of "emacs."

7.1.1 Notes on the Tables

Emacs commands use the Control key and the Meta key (Meta is usually the ESCAPE key). In this section, the notation C- indicates that the Control key is pressed at the same time as the character that follows. Similarly, M- indicates the use of the Meta key. It's not necessary, however, to keep the Meta key pressed down while typing the next key.

In the command tables that follow, the first column lists the keystroke and the last column describes it. When there is a middle column, it lists the command name. This name is accessed by typing M-x followed by the command name. If you're unsure of the name, you can type a space or a carriage return, and emacs will list possible completions of what you've typed so far.

Because emacs is such a comprehensive editor, containing hundreds of commands, some commands must be omitted for the sake of preserving a "quick" reference. You can browse the command set by typing C-h (for help) or M-x (for command names).

7.1.2 Absolutely Essential Commands

If you're just getting started with emacs, here's a short list of the most important commands to know:

C-h

Enter the online help system.

C-x C-s

Save the file.

C-x C-c

Exit emacs.

C-x u

Undo last edit (can be repeated).

C-g

Get out of current command operation.

C-p

Up/down/forward/back by line or character.

C-n

C-f

C-b

C-v

Forward/backward by one screen.

M-v

C-s

Search for characters.

C-d

Delete a character.

Previous: 6.4 Examples of Searching | UNIX in a Nutshell: System V Edition | Next: 7.2 Summary of Commands by Group
6.4 Examples of Searching | Book Index | 7.2 Summary of Commands by Group


[Chapter 7] 7.2 Summary of Commands by Group

Previous: 7.1 Introduction Chapter 7
The Emacs Editor 		Next: 7.3 Summary of Commands by Key

7.2 Summary of Commands by Group

Reminder: Tables list keystrokes, command name, and description. C- indicates the Control key; M- indicates the Meta key.

7.2.1 File-handling Commands

C-x C-f | find-file | Find file and read it.
C-x C-v | find-alternate-file | Read another file; replace the one read with C-x C-f.
C-x i | insert-file | Insert file at cursor position.
C-x C-s | save-buffer | Save file (may hang terminal; use C-q to restart).
C-x C-w | write-file | Write buffer contents to file.
C-x C-c | save-buffers-kill-emacs | Exit emacs.
C-z | suspend-emacs | Suspend emacs (use exit or fg to restart).

7.2.2 Cursor Movement Commands

C-f | forward-char | Move forward one character (right).
C-b | backward-char | Move backward one character (left).
C-p | previous-line | Move to previous line (up).
C-n | next-line | Move to next line (down).
M-f | forward-word | Move one word forward.
M-b | backward-word | Move one word backward.
C-a | beginning-of-line | Move to beginning of line.
C-e | end-of-line | Move to end of line.
M-a | backward-sentence | Move backward one sentence.
M-e | forward-sentence | Move forward one sentence.
M-[ | backward-paragraph | Move backward one paragraph.
M-] | forward-paragraph | Move forward one paragraph.
C-v | scroll-up | Move forward one screen.
M-v | scroll-down | Move backward one screen.
C-x [ | backward-page | Move backward one page.
C-x ] | forward-page | Move forward one page.
M-> | end-of-buffer | Move to end of file.
M-< | beginning-of-buffer | Move to beginning of file.
(none) | goto-line | Go to line n of file.
(none) | goto-char | Go to character n of file.
C-l | recenter | Redraw screen with current line in the center.
M-n | digit-argument | Repeat the next command n times.
C-u n | universal-argument | Repeat the next command n times.

7.2.3 Deletion Commands

DEL | backward-delete-char | Delete previous character.
C-d | delete-char | Delete character under cursor.
M-DEL | backward-kill-word | Delete previous word.
M-d | kill-word | Delete the word the cursor is on.
C-k | kill-line | Delete from cursor to end of line.
M-k | kill-sentence | Delete sentence the cursor is on.
C-x DEL | backward-kill-sentence | Delete previous sentence.
C-y | yank | Restore what you've deleted.
C-w | kill-region | Delete a marked region (see next section).
(none) | backward-kill-paragraph | Delete previous paragraph.
(none) | kill-paragraph | Delete from the cursor to the end of the paragraph.

7.2.4 Paragraphs and Regions

C-@ | set-mark-command | Mark the beginning (or end) of a region.
C-SPACE | (same as above) |
C-x C-p | mark-page | Mark page.
C-x C-x | exchange-point-and-mark | Exchange location of cursor and mark.
C-x h | mark-whole-buffer | Mark buffer.
M-q | fill-paragraph | Reformat paragraph.
M-q | fill-region | Reformat individual paragraphs within a region.
M-h | mark-paragraph | Mark paragraph.

7.2.5 Stopping and Undoing Commands

C- | keyboard-quit | Abort current command.
C-x u | advertised-undo | Undo last edit (can be done repeatedly).
(none) | revert-buffer | Restore buffer to the state it was in when the file was last saved (or auto-saved).

7.2.6 Transposition Commands

C-t | transpose-chars | Transpose two letters.
M-t | transpose-words | Transpose two words.
C-x C-t | transpose-lines | Transpose two lines.
(none) | transpose-sentences | Transpose two sentences.
(none) | transpose-paragraphs | Transpose two paragraphs.

7.2.7 Capitalization Commands

M-c | capitalize-word | Capitalize first letter of word.
M-u | upcase-word | Uppercase word.
M-l | downcase-word | Lowercase word.
M- - M-c | negative-argument; capitalize-word | Capitalize previous word.
M- - M-u | negative-argument; upcase-word | Uppercase previous word.
M- - M-l | negative-argument; downcase-word | Lowercase previous word.
(none) | capitalize-region | Capitalize region.
C-x C-u | upcase-region | Uppercase region
C-x C-l | downcase-region | Lowercase region.

7.2.8 Incremental Search Commands

C-s | isearch-forward | Start incremental search forward.
C-r | isearch-backward | Start incremental search backward.
Meta | (none) | Exit a successful search.
C-g | keyboard-quit | Cancel incremental search; return to starting point.
DEL | (none) | Delete incorrect character of search string.

7.2.9 Word Abbreviation Commands

(none) | abbrev-mode | Enter (or exit) word abbreviation mode.
C-x - | inverse-add-lobal-abbrev | Type global abbreviation, then definition.
C-x C-h | inverse-add-local-abbrev | Type local abbreviation, then definition.
(none) | unexpand-abbrev | Undo the last word abbreviation.
(none) | write-abbrev-file | Write the word abbreviation file.
(none) | edit-abbrevs | Edit the word abbreviations.
(none) | list-abbrevs | View the word abbreviations.
(none) | kill-all-abbrevs | Kill abbreviations for this session.

7.2.10 Buffer Manipulation Commands

C-x b | switch-to-buffer | Move to specified buffer.
C-x C-b | list-buffers | Display buffer list.
C-x k | kill-buffer | Delete specified buffer.
(none) | kill-some-buffers | Ask about deleting each buffer.
(none) | rename-buffer | Change buffer name to specified name.
C-x s | save-some-buffers | Ask whether to save each modified buffer.

7.2.11 Window Commands

C-x 2 | split-window-horizontally | Divide the current window horizontally into two.
C-x 5 | split-window-vertically | Divide the current window vertically into two.
C-x > | scroll-right | Scroll the window right.
C-x < | scroll-left | Scroll the window left.
C-x o | other-window | Move to the other window.
C-x 0 | delete-window | Delete current window.
C-x 1 | delete-other-windows | Delete all windows but this one.
(none) | delete-windows-on | Delete all windows on a given buffer.
C-x ^ | enlarge-window | Make window taller.
(none) | shrink-window | Make window shorter.
C-x } | enlarge-window-horizontally | Make window wider.
C-x { | shrink-window-horizontally | Make window narrower.
M-C-v | scroll-other-window | Scroll other window.
C-x 4 f | find-file-other-window | Find a file in the other window.
C-x 4 b | switch-to-buffer-other-window | Select a buffer in the other window.
(none) | compare-windows | Compare two buffers; show first difference.

7.2.12 Special Shell Characters

C-c C-c | interrupt-shell-subjob | Terminate the current job.
C-c C-d | shell-send-eof | End of file character.
C-c C-u | kill-shell-input | Erase current line.
C-c C-w | backward-kill-word | Erase the previous word.
C-c C-z | stop-shell-subjob | Suspend the current job.

7.2.13 Indentation Commands

C-x . | set-fill-prefix | Prepend each line in paragraph with characters from beginning of line up to cursor column; cancel prefix by typing this command in column 1.
(none) | indented-text-mode | Major mode: each tab defines a new indent for subsequent lines.
(none) | text-mode | Exit indented text mode; return to text mode.
M-C-\ | indent-region | Indent a region to match first line in region.
M-m | back-to-indentation | Move cursor to first character on line.
M-C-o | split-line | Split line at cursor; indent to column of cursor.
(none) | fill-individual- paragraphs | Reformat indented paragraphs, keeping indentation.

7.2.14 Centering Commands

M-s | center-line | Center line that cursor is on.
(none) | center-paragraph | Center paragraph that cursor is on.
(none) | center-region | Center currently defined region.

7.2.15 Macro Commands

C-x ( | start-kbd-macro | Start macro definition.
C-x ) | end-kbd-macro | End macro definition.
C-x e | call-last-kbd-macro | Execute last macro defined.
M-n C-x e | digit-argument and call-last-kbd-macro | Execute last macro defined, n times.
C-u C-x ( | start-kbd-macro | Execute last macro defined, then add keystrokes.
(none) | name-last-kbd-macro | Name last macro you created (before saving it).
(none) | insert-last-keyboard-macro | Insert the macro you named into a file.
(none) | load-file | Load macro files you've saved.
(none) | macroname | Execute a keyboard macro you've saved.
C-x q | kbd-macro-query | Insert a query in a macro definition.
C-u C-x q | (none) | Insert a recursive edit in a macro definition.
M-C-c | exit-recursive-edit | Exit a recursive edit.

7.2.16 Basic Indentation Commands

M-C-\ | indent-region | Indent a region to match first line in region.
M-m | back-to-indentation | Move to first non-blank character on line.
M-^ | delete-indentation | Join this line to the previous one.

7.2.17 Detail Information Help Commands

C-h a | command-apropos | What commands involve this concept?
(none) | apropos | What functions and variables involve this concept?
C-h c | describe-key-briefly | What command does this keystroke sequence run?
C-h b | describe-bindings | What are all the key bindings for this buffer?
C-h k | describe-key | What command does this keystroke sequence run, and what does it do?
C-h l | view-lossage | What are the last 100 characters I typed?
C-h w | where-is | What is the key binding for this command?
C-h f | describe-function | What does this function do?
C-h v | describe-variable | What does this variable mean, and what is its value?
C-h m | describe-mode | Tell me about the mode the current buffer is in.
C-h s | describe-syntax | What is the syntax table for this buffer?

7.2.18 Help Commands

C-h t | help-with-tutorial | Run the emacs tutorial.
C-h i | info | Start the info documentation reader.
C-h n | view-emacs-news | View news about updates to emacs.
C-h C-c | describe-copying | View the emacs General Public License.
C-h C-d | describe-distribution | View information on ordering emacs from FSF.
C-h C-w | describe-no-warranty | View the (non-)warranty for emacs.

Previous: 7.1 Introduction | UNIX in a Nutshell: System V Edition | Next: 7.3 Summary of Commands by Key
7.1 Introduction | Book Index | 7.3 Summary of Commands by Key


[Chapter 7] 7.3 Summary of Commands by Key

Previous: 7.2 Summary of Commands by Group Chapter 7
The Emacs Editor 		Next: 7.4 Summary of Commands by Name

7.3 Summary of Commands by Key

Emacs commands are presented below in two alphabetical lists. Reminder: Tables list keystrokes, command name, and description. C- indicates the Control key; M- indicates the Meta key.

7.3.1 Control-key Sequences

C-@ | set-mark-command | Mark the beginning (or end) of a region.
C-SPACE | (same as previous) |
C-] | (none) | Exit recursive edit and exit query-replace.
C-a | beginning-of-line | Move to beginning of line.
C-b | backward-char | Move backward one character (left).
C-c C-c | interrupt-shell-subjob | Terminate the current job.
C-c C-d | shell-send-eof | End of file character.
C-c C-u | kill-shell-input | Erase current line.
C-c C-w | backward-kill-word | Erase the previous word.
C-c C-z | stop-shell-subjob | Suspend the current job.
C-d | delete-char | Delete character under cursor.
C-e | end-of-line | Move to end of line.
C-f | forward-char | Move forward one character (right).
C- | keyboard-quit | Abort current command.
C-h | help-command | Enter the online help system.
C-h a | command-apropos | What commands involve this concept?
C-h b | describe-bindings | What are all the key bindings for this buffer?
C-h C-c | describe-copying | View the emacs General Public License.
C-h C-d | describe-distribution | View information on ordering emacs from FSF.
C-h C-w | describe-no-warranty | View the (non-)warranty for emacs.
C-h c | describe-key-briefly | What command does this keystroke sequence run?
C-h f | describe-function | What does this function do?
C-h i | info | Start the info documentation reader.
C-h k | describe-key | What command does this keystroke sequence run, and what does it do?
C-h l | view-lossage | What are the last 100 characters I typed?
C-h m | describe-mode | Tell me about the mode the current buffer is in.
C-h n | view-emacs-news | View news about updates to emacs.
C-h s | describe-syntax | What is the syntax table for this buffer?
C-h t | help-with-tutorial | Run the emacs tutorial.
C-h v | describe-variable | What does this variable mean, and what is its value?
C-h w | where-is | What is the key binding for this command?
C-k | kill-line | Delete from cursor to end of line.
C-l | recenter | Redraw screen with current line in the center.
C-n | next-line | Move to next line (down).
C-p | previous-line | Move to previous line (up).
C-r Meta | (none) | Start nonincremental search backwards.
C-r | (none) | Repeat nonincremental search backward.
C-r | (none) | Enter recursive edit (during query replace).
C-r | isearch-backward | Start incremental search backward.
C-s Meta | (none) | Start nonincremental search forward.
C-s | (none) | Repeat nonincremental search forward.
C-s | isearch-forward | Start incremental search forward.
C-t | transpose-chars | Transpose two letters.
C-u n | universal-argument | Repeat the next command n times.
C-u C-x ( | start-kbd-macro | Execute last macro defined, then add keystrokes.
C-u C-x q | (none) | Insert recursive edit in a macro definition.
C-v | scroll-up | Move forward one screen.
C-w | kill-region | Delete a marked region.
C-x ( | start-kbd-macro | Start macro definition.
C-x ) | end-kbd-macro | End macro definition.
C-x [ | backward-page | Move backward one page.
C-x ] | forward-page | Move forward one page.
C-x ^ | enlarge-window | Make window taller.
C-x { | shrink-window- horizontally | Make window narrower.
C-x } | enlarge-window-horizontally | Make window wider.
C-x < | scroll-left | Scroll the window left.
C-x > | scroll-right | Scroll the window right.
C-x - | inverse-add-lobal-abbrev | Type global abbreviation, then definition.
C-x . | set-fill-prefix | Prepend each line in paragraph with characters from beginning of line up to cursor column; cancel prefix by typing this command in column 1.
C-x 0 | delete-window | Delete current window.
C-x 1 | delete-other-windows | Delete all windows but this one.
C-x 2 | split-window-horizontally | Divide current window horizontally into two.
C-x 4 b | switch-to-buffer-other-window | Select a buffer in the other window.
C-x 4 f | find-file-other-window | Find a file in the other window.
C-x 5 | split-window-vertically | Divide current window vertically into two.
C-x b | switch-to-buffer | Move to the buffer specified.
C-x C-b | list-buffers | Display the buffer list.
C-x C-c | save-buffers-kill-emacs | Exit emacs.
C-x C-f | find-file | Find file and read it.
C-x C-h | inverse-add-local-abbrev | Type local abbreviation, then definition.
C-x C-l | downcase-region | Lowercase region.
C-x C-p | mark-page | Mark page.
C-x C-q | (none) | Toggle read-only status of buffer.
C-x C-s | save-buffer | Save file (may hang terminal; use C-q to restart).
C-x C-t | transpose-lines | Transpose two lines.
C-x C-u | upcase-region | Uppercase region
C-x C-v | find-alternate-file | Read an alternate file, replacing the one read with C-x C-f.
C-x C-w | write-file | Write buffer contents to file.
C-x C-x | exchange-point-and-mark | Exchange location of cursor and mark.
C-x DEL | backward-kill-sentence | Delete previous sentence.
C-x e | call-last-kbd-macro | Execute last macro defined.
C-x h | mark-whole-buffer | Mark buffer.
C-x i | insert-file | Insert file at cursor position.
C-x k | kill-buffer | Delete the buffer specified.
C-x o | other-window | Move to the other window.
C-x q | kbd-macro-query | Inserts a query in a macro definition.
C-x s | save-some-buffers | Ask whether to save each modified buffer.
C-x u | advertised-undo | Undo last edit (can be done repeatedly).
C-y | yank | Restore what you've deleted.
C-z | suspend-emacs | Suspend emacs (use exit or fg to restart).

7.3.2 Meta-key Sequences

Meta | (none) | Exit a query-replace or successful search.
M- - M-c | negative-argument; capitalize-word | Capitalize previous word.
M- - M-l | negative-argument; downcase-word | Lowercase previous word.
M- - M-u | negative-argument; upcase-word | Uppercase previous word.
M-$ | spell-word | Check spelling of word after cursor.
M-< | beginning-of-buffer | Move to beginning of file.
M-> | end-of-buffer | Move to end of file.
M-[ | backward-paragraph | Move backward one paragraph.
M-] | forward-paragraph | Move forward one paragraph.
M-^ | delete-indentation | Join this line to the previous one.
M-n | digit-argument | Repeat the next command n times.
M-n C-x e | digit-argument and call-last-kbd-macro | Execute the last defined macro, n times.
M-a | backward-sentence | Move backward one sentence.
M-b | backward-word | Move one word backward.
M-C-\ | indent-region | Indent a region to match first line in region.
M-C-c | exit-recursive-edit | Exit a recursive edit.
M-C-o | split-line | Split line at cursor; indent to column of cursor.
M-C-v | scroll-other-window | Scroll other window.
M-c | capitalize-word | Capitalize first letter of word.
M-d | kill-word | Delete word that cursor is on.
M-DEL | backward-kill-word | Delete previous word.
M-e | forward-sentence | Move forward one sentence.
M-f | forward-word | Move one word forward.
M- | fill-region | Reformat individual paragraphs within a region.
M-h | mark-paragraph | Mark paragraph.
M-k | kill-sentence | Delete sentence the cursor is on.
M-l | downcase-word | Lowercase word.
M-m | back-to-indentation | Move cursor to first non-blank character on line.
M-q | fill-paragraph | Reformat paragraph.
M-s | center-line | Center line that cursor is on.
M-t | transpose-words | Transpose two words.
M-u | upcase-word | Uppercase word.
M-v | scroll-down | Move backward one screen.
M-x | (none) | Access text name of command keystrokes.

Previous: 7.2 Summary of Commands by Group | UNIX in a Nutshell: System V Edition | Next: 7.4 Summary of Commands by Name
7.2 Summary of Commands by Group | Book Index | 7.4 Summary of Commands by Name


[Chapter 7] 7.4 Summary of Commands by Name

Previous: 7.3 Summary of Commands by Key Chapter 7
The Emacs Editor 		Next: 8. The Vi Editor

7.4 Summary of Commands by Name

The emacs commands below are presented alphabetically by command name. Use M-x to access the command name. Reminder: Tables list command name, keystroke, and description. C- indicates the Control key; M- indicates the Meta key.

macroname | (none) | Execute a keyboard macro you've saved.
abbrev-mode | (none) | Enter (or exit) word abbreviation mode.
advertised-undo | C-x u | Undo last edit (can be done repeatedly).
apropos | (none) | What functions and variables involve this concept?
back-to-indentation | M-m | Move cursor to first non-blank character on line.
backward-char | C-b | Move backward one character (left).
backward-delete-char | DEL | Delete previous character.
backward-kill-paragraph | (none) | Delete previous paragraph.
backward-kill-sentence | C-x DEL | Delete previous sentence.
backward-kill-word | C-c C-w | Erase previous word.
backward-kill-word | M-DEL | Delete previous word.
backward-page | C-x [ | Move backward one page.
backward-paragraph | M-[ | Move backward one paragraph.
backward-sentence | M-a | Move backward one sentence.
backward-word | M-b | Move backward one word.
beginning-of-buffer | M-< | Move to beginning of file.
beginning-of-line | C-a | Move to beginning of line.
call-last-kbd-macro | C-x e | Execute last macro defined.
capitalize-region | (none) | Capitalize region.
capitalize-word | M-c | Capitalize first letter of word.
center-line | M-s | Center line that cursor is on.
center-paragraph | (none) | Center paragraph that cursor is on.
center-region | (none) | Center currently defined region.
command-apropos | C-h a | What commands involve this concept?
compare-windows | (none) | Compare two buffers; show first difference.
delete-char | C-d | Delete character under cursor.
delete-indentation | M-^ | Join this line to previous one.
delete-other-windows | C-x 1 | Delete all windows but this one.
delete-window | C-x 0 | Delete current window.
delete-windows-on | (none) | Delete all windows on a given buffer.
describe-bindings | C-h b | What are all the key bindings for in this buffer?
describe-copying | C-h C-c | View the emacs General Public License.
describe-distribution | C-h C-d | View information on ordering emacs from FSF.
describe-function | C-h f | What does this function do?
describe-key | C-h k | What command does this keystroke sequence run, and what does it do?
describe-key-briefly | C-h c | What command does this keystroke sequence run?
describe-mode | C-h m | Tell me about the mode the current buffer is in.
describe-no-warranty | C-h C-w | View the (non-)warranty for emacs.
describe-syntax | C-h s | What is the syntax table for this buffer?
describe-variable | C-h v | What does this variable mean, and what is its value?
digit-argument and call-last-kbd-macro | M-n C-x e | Execute the last defined macro, n times.
digit-argument | M-n | Repeat next command, n times.
downcase-region | C-x C-l | Lowercase region.
downcase-word | M-l | Lowercase word.
edit-abbrevs | (none) | Edit word abbreviations.
end-kbd-macro | C-x ) | End macro definition.
end-of-buffer | M-> | Move to end of file.
end-of-line | C-e | Move to end of line.
enlarge-window | C-x ^ | Make window taller.
enlarge-window-horizontally | C-x } | Make window wider.
exchange-point-and-mark | C-x C-x | Exchange location of cursor and mark.
exit-recursive-edit | M-C-c | Exit a recursive edit.
fill-individual-paragraphs | (none) | Reformat indented paragraphs, keeping indentation.
fill-paragraph | M-q | Reformat paragraph.
fill-region | M- | Reformat individual paragraphs within a region.
find-alternate-file | C-x C-v | Read an alternate file, replacing the one read with C-x C-f.
find-file | C-x C-f | Find file and read it.
find-file-other-window | C-x 4 f | Find a file in the other window.
forward-char | C-f | Move forward one character (right).
forward-page | C-x ] | Move forward one page.
forward-paragraph | M-] | Move forward one paragraph.
forward-sentence | M-e | Move forward one sentence.
forward-word | M-f | Move forward one word.
goto-char | (none) | Go to character n of file.
goto-line | (none) | Go to line n of file.
help-command | C-h | Enter the online help system.
help-with-tutorial | C-h t | Run the emacs tutorial.
indent-region | M-C-\ | Indent a region to match first line in region.
indented-text-mode | (none) | Major mode: each tab defines a new indent for subsequent lines.
info | C-h i | Start the info documentation reader.
insert-file | C-x i | Insert file at cursor position.
insert-last-keyboard-macro | (none) | Insert the macro you named into a file.
interrupt-shell-subjob | C-c C-c | Terminate the current job.
inverse-add-lobal-abbrev | C-x - | Type global abbreviation, then definition.
inverse-add-local-abbrev | C-x C-h | Type local abbreviation, then definition.
isearch-backward | C-r | Start incremental search backward.
isearch-backward-regexp | C-r | Same, but search for regular expression.
isearch-forward | C-s | Start incremental search forward.
isearch-forward-regexp | C-r | Same, but search for regular expression.
kbd-macro-query | C-x q | Insert a query in a macro definition.
keyboard-quit | C- | Abort current command.
kill-all-abbrevs | (none) | Kill abbreviations for this session.
kill-buffer | C-x k | Delete the buffer specified.
kill-line | C-k | Delete from cursor to end of line.
kill-paragraph | (none) | Delete from cursor to end of paragraph.
kill-region | C-w | Delete a marked region.
kill-sentence | M-k | Delete sentence the cursor is on.
kill-shell-input | C-c C-u | Erase current line.
kill-some-buffers | (none) | Ask about deleting each buffer.
kill-word | M-d | Delete word the cursor is on.
list-abbrevs | (none) | View word abbreviations.
list-buffers | C-x C-b | Display buffer list.
load-file | (none) | Load macro files you've saved.
mark-page | C-x C-p | Mark page.
mark-paragraph | M-h | Mark paragraph.
mark-whole-buffer | C-x h | Mark buffer.
name-last-kbd-macro | (none) | Name last macro you created (before saving it).
negative-argument; capitalize-word | M- - M-c | Capitalize previous word.
negative-argument; downcase-word | M- - M-l | Lowercase previous word.
negative-argument; upcase-word | M- - M-u | Uppercase previous word.
next-line | C-n | Move to next line (down).
other-window | C-x o | Move to the other window.
previous-line | C-p | Move to previous line (up).
query-replace-regexp | (none) | Query-replace a regular expression.
recenter | C-l | Redraw screen, with current line in center.
rename-buffer | (none) | Change buffer name to specified name.
replace-regexp | (none) | Replace a regular expression unconditionally.
re-search-backward | (none) | Simple regular expression search backward.
re-search-forward | (none) | Simple regular expression search forward.
revert-buffer | (none) | Restore buffer to the state it was in when the file was last saved (or auto-saved).
save-buffer | C-x C-s | Save file (may hang terminal; use C-q to restart).
save-buffers-kill-emacs | C-x C-c | Exit emacs.
save-some-buffers | C-x s | Ask whether to save each modified buffer.
scroll-down | M-v | Move backward one screen.
scroll-left | C-x < | Scroll the window left.
scroll-other-window | M-C-v | Scroll other window.
scroll-right | C-x > | Scroll the window right.
scroll-up | C-v | Move forward one screen.
set-fill-prefix | C-x . | Prepend each line in paragraph with characters from beginning of line up to cursor column; cancel prefix by typing this command in column 1.
set-mark-command | C-@ or C-SPACE | Mark the beginning (or end) of a region.
shell-send-eof | C-c C-d | End of file character.
shrink-window | (none) | Make window shorter.
shrink-window-horizontally | C-x { | Make window narrower.
spell-buffer | (none) | Check spelling of current buffer.
spell-region | (none) | Check spelling of current region.
spell-string | (none) | Check spelling of string typed in minibuffer.
spell-word | M-$ | Check spelling of word after cursor.
split-line | M-C-o | Split line at cursor; indent to column of cursor.
split-window-horizontally | C-x 2 | Divide current window horizontally into two.
split-window-vertically | C-x 5 | Divide current window vertically into two.
start-kbd-macro | C-u C-x ( | Execute last macro defined, then add keystrokes to it.
start-kbd-macro | C-x ( | Start macro definition.
stop-shell-subjob | C-c C-z | Suspend current job.
suspend-emacs | C-z | Suspend emacs (use exit or fg to restart).
switch-to-buffer | C-x b | Move to the buffer specified.
switch-to-buffer-other- window | C-x 4 b | Select a buffer in the other window.
text-mode | (none) | Exit indented text mode; return to text mode.
transpose-chars | C-t | Transpose two letters.
transpose-lines | C-x C-t | Transpose two lines.
transpose-paragraphs | (none) | Transpose two paragraphs.
transpose-sentences | (none) | Transpose two sentences.
transpose-words | M-t | Transpose two words.
unexpand-abbrev | (none) | Undo the last word abbreviation.
universal-argument | C-u n | Repeat the next command n times.
upcase-region | C-x C-u | Uppercase region.
upcase-word | M-u | Uppercase word.
view-emacs-news | C-h n | View news about updates to emacs.
view-lossage | C-h l | What are the last 100 characters I typed?
where-is | C-h w | What is the key binding for this command?
write-abbrev-file | (none) | Write the word abbreviation file.
write-file | C-x C-w | Write buffer contents to file.
yank | C-y | Restore what you've deleted.

Previous: 7.3 Summary of Commands by Key | UNIX in a Nutshell: System V Edition | Next: 8. The Vi Editor
7.3 Summary of Commands by Key | Book Index | 8. The Vi Editor


[Chapter 8] The Vi Editor

Previous: 7.4 Summary of Commands by Name Chapter 8 Next: 8.2 Movement Commands

8. The Vi Editor

Contents:
Review of Vi Operations
Movement Commands
Edit Commands
Saving and Exiting
Accessing Multiple Files
Interacting with UNIX
Macros
Miscellaneous Commands
Alphabetical List of Keys
Setting Up Vi

This section presents the following topics:

  • Review of vi operations

  • Movement commands

  • Edit commands

  • Saving and exiting

  • Accessing multiple files

  • Interacting with UNIX

  • Macros

  • Miscellaneous commands

  • Alphabetical list of keys

  • Setting up vi

8.1 Review of Vi Operations

This subsection provides a review of the following:

  • Command-line syntax

  • Vi modes

  • Syntax of vi commands

  • Status-line commands

For more information on vi, refer to the Nutshell Handbook Learning the vi Editor.

8.1.1 Command-line Syntax

The three most common ways of starting a vi session are:

vi file vi +n file vi +/pattern file

You can open file for editing, optionally at line n or at the first line matching pattern. If no file is specified, vi opens with an empty buffer. See Section 2 for more information on command-line options for vi.

8.1.2 Command Mode

Once the file is opened, you are in command mode. From command mode, you can:

  • Invoke insert mode

  • Issue editing commands

  • Move the cursor to a different position in the file

  • Invoke ex commands

  • Invoke a UNIX shell

  • Save or exit the current version of the file

8.1.3 Insert Mode

In insert mode, you can enter new text in the file. Press the ESCAPE key to exit insert mode and return to command mode. The following commands invoke insert mode:

a | Append after cursor.
A | Append at end of line.
c | Begin change operation.
C | Change to end of line.
i | Insert before cursor.
I | Insert at beginning of line.
o | Open a line below current line.
O | Open a line above current line.
R | Begin overwriting text.
s | Substitute a character.
S | Substitute entire line.

8.1.4 Syntax of Vi Commands

In vi, commands have the following general form:

[n] operator [m] object

The basic editing operators are:

c | Begin a change.
d | Begin a deletion.
y | Begin a yank (or copy).

If the current line is the object of the operation, then the operator is the same as the object: cc, dd, yy. Otherwise, the editing operators act on objects specified by cursor-movement commands or pattern-matching commands. n and m are the number of times the operation is performed, or the number of objects the operation is performed on. If both n and m are specified, the effect is n X m.

An object can represent any of the following text blocks:

word | Includes characters up to a space or punctuation mark. A capitalized object is a variant form that recognizes only blank spaces.
sentence | Is up to ., !, ? followed by two spaces.
paragraph | Is up to next blank line or paragraph macro defined by para= option.
section | Is up to next section heading defined by sect= option.

8.1.4.1 Examples

2cw | Change the next two words.
d} | Delete up to next paragraph.
d^ | Delete back to beginning of line.
5yy | Copy the next five lines.
y]] | Copy up to the next section.

8.1.5 Status-line Commands

Most commands are not echoed on the screen as you input them. However, the status line at the bottom of the screen is used to echo input for the following commands:

/ | Search forward for a pattern.
? | Search backward for a pattern.
: | Invoke an ex command.
! | Invoke a UNIX command that takes as its input an object in the buffer and replaces it with output from the command.

Commands that are input on the status line must be entered by pressing the RETURN key. In addition, error messages and output from the CTRL-G command are displayed on the status line.

Previous: 7.4 Summary of Commands by Name | UNIX in a Nutshell: System V Edition | Next: 8.2 Movement Commands
7.4 Summary of Commands by Name | Book Index | 8.2 Movement Commands


[Chapter 8] 8.2 Movement Commands

Previous: 8.1 Review of Vi Operations Chapter 8
The Vi Editor 		Next: 8.3 Edit Commands

8.2 Movement Commands

A number preceding a command repeats the movement. Movement commands are also objects for change, delete, and yank operations.

8.2.1 Character

h, j, k, l | Left, down, up, right (<-, -v , [image] , ->).
SPACEBAR | Right.

8.2.2 Text

w, W, b, B | Forward, backward by word.
e, E | End of word.
), ( | Beginning of next, current sentence.
}, { | Beginning of next, current paragraph.
]], [[ | Beginning of next, current section.

8.2.3 Lines

0, $ | First, last position of current line.
^ | First nonblank character of current line.
+, - | First character of next, previous line.
RETURN | First character of next line.
n| | Column n of current line.
H | Top line of screen.
M | Middle line of screen.
L | Last line of screen.
nH | n lines after top line.
nL | n lines before last line.

8.2.4 Screens

CTRL-F, CTRL-B | Scroll forward, backward one screen.
CTRL-D, CTRL-U | Scroll down, up one-half screen.
CTRL-E, CTRL-Y | Show one more line at bottom, top of window.
z RETURN | Reposition line with cursor: to top of screen.
z. | Reposition line with cursor: to middle of screen.
z- | Reposition line with cursor: to bottom of screen.
CTRL-L, CTRL-R | Redraw screen (without scrolling).

8.2.5 Searches

/text | Search forward for text.
n | Repeat previous search.
N | Repeat search in opposite direction.
/ | Repeat forward search.
? | Repeat previous search backward.
?text | Search backward for text.
/text/+n | Go to line n after text.
?text?-n | Go to line n before text.
% | Find match of current parenthesis, brace, or bracket.
fx | Move search forward to x on current line.
Fx | Move search backward to x on current line.
tx | Search forward before x in current line.
Tx | Search back after x in current line.
, | Reverse search direction of last f, F, t, or T.
; | Repeat last character search (f, F, t, or T).

8.2.6 Line Numbering

CTRL-G | Display current line number.
nG | Move to line number n.
G | Move to last line in file.
:n | Move to line number n.

8.2.7 Marking Position

mx | Mark current position with character x.
`x | Move cursor to mark x.
'x | Move to start of line containing x.
`` | Return to previous mark (or to location prior to a search).
'' | Like above, but return to start of line.

Previous: 8.1 Review of Vi Operations | UNIX in a Nutshell: System V Edition | Next: 8.3 Edit Commands
8.1 Review of Vi Operations | Book Index | 8.3 Edit Commands


[Chapter 8] 8.3 Edit Commands

Previous: 8.2 Movement Commands Chapter 8
The Vi Editor 		Next: 8.4 Saving and Exiting

8.3 Edit Commands

Recall that c, d, and y are the basic editing operators.

8.3.1 Inserting New Text

a | Append after cursor.
A | Append to end of line.
i | Insert before cursor.
I | Insert at beginning of line.
o | Open a line below cursor.
O | Open a line above cursor.
ESC | Terminate insert mode.
CTRL-J | Move down one line.
RETURN | Move down one line.
CTRL-I | Insert a tab.
CTRL-T | Move to next tab setting.
BACKSPACE | Move back one character.
CTRL-H | Move back one character.
CTRL-U | Delete current line.
CTRL-V | Quote next character.
CTRL-W | Move back one word.

The last four control characters are set by stty. Your terminal settings may differ.

8.3.2 Changing and Deleting Text

cw | Change word.
cc | Change line.
C | Change text from current position to end of line.
dd | Delete current line.
ndd | Delete n lines.
D | Delete remainder of line.
dw | Delete a word.
d} | Delete up to next paragraph.
d^ | Delete back to beginning of line.
d/pat | Delete up to first occurrence of pattern.
dn | Delete up to next occurrence of pattern.
dfa | Delete up to and including a on current line.
dta | Delete up to (not including) a on current line.
dL | Delete up to last line on screen.
dG | Delete to end of file.
p | Insert last deleted text after cursor.
P | Insert last deleted text before cursor.
rx | Replace character with x.
Rtext | Replace text beginning at cursor.
s | Substitute character.
4s | Substitute four characters.
S | Substitute entire line.
u | Undo last change.
U | Restore current line.
x | Delete current cursor position.
X | Delete back one character.
5X | Delete previous five characters.
. | Repeat last change.
~ | Reverse case.

8.3.3 Copying and Moving

Y | Copy current line to new buffer.
yy | Copy current line.
"xyy | Yank current line to buffer x.
"xd | Delete into buffer x.
"Xd | Delete and append into buffer x.
"xp | Put contents of buffer x.
y]] | Copy up to next section heading.
ye | Copy to end of word.

Previous: 8.2 Movement Commands | UNIX in a Nutshell: System V Edition | Next: 8.4 Saving and Exiting
8.2 Movement Commands | Book Index | 8.4 Saving and Exiting


[Chapter 8] 8.4 Saving and Exiting

Previous: 8.3 Edit Commands Chapter 8
The Vi Editor 		Next: 8.5 Accessing Multiple Files

8.4 Saving and Exiting

Writing a file means saving the edits and updating the file's modification time.

ZZ | Quit vi, writing the file only if changes were made.
:x | Same as ZZ.
:wq | Write and quit file.
:w | Write file.
:w file | Save copy to file.
:n1,n2w file | Write lines n1 to n2 to new file.
:n1,n2w >> file | Append lines n1 to n2 to existing file.
:w! | Write file (overriding protection).
:w! file | Overwrite file with current buffer.
:w %.new | Write current buffer named file as file.new.
:q | Quit file.
:q! | Quit file (discarding edits).
Q | Quit vi and invoke ex.
:vi | Return to vi after Q command.
:e file2 | Edit file2 without leaving vi.
:n | Edit next file.
:e! | Return to version of current file at time of last write.
:e# | Edit alternate file.
% | Current filename.
# | Alternate filename.

Previous: 8.3 Edit Commands | UNIX in a Nutshell: System V Edition | Next: 8.5 Accessing Multiple Files
8.3 Edit Commands | Book Index | 8.5 Accessing Multiple Files


[Chapter 8] 8.5 Accessing Multiple Files

Previous: 8.4 Saving and Exiting Chapter 8
The Vi Editor 		Next: 8.6 Interacting with UNIX

8.5 Accessing Multiple Files

:e file | Edit another file; current file becomes alternate.
:e! | Restore last saved version of current file.
:e + file | Begin editing at end of file.
:e +n file | Open file at line n.
:e # | Open to previous position in alternate file.
:ta tag | Edit file at location tag.
:n | Edit next file.
:n! | Forces next file.
:n files | Specify new list of files.
CTRL-G | Show current file and line number.
:args | Display multiple files to be edited.
:rew | Rewind list of multiple files to top.

Previous: 8.4 Saving and Exiting | UNIX in a Nutshell: System V Edition | Next: 8.6 Interacting with UNIX
8.4 Saving and Exiting | Book Index | 8.6 Interacting with UNIX


[Chapter 8] 8.6 Interacting with UNIX

Previous: 8.5 Accessing Multiple Files Chapter 8
The Vi Editor 		Next: 8.7 Macros

8.6 Interacting with UNIX

:r file | Read in contents of file after cursor.
:r !command | Read in output from command after current line.
:nr !command | Like above, but place after line n (0 for top of file).
:!command | Run command, then return.
!object command | Send buffer object to UNIX command; replace with output.
:n1,n2! command | Send lines n1 -n2 to command; replace with output.
n!!command | Send n lines to UNIX command; replace with output.
!! | Repeat last system command.
:sh | Create subshell; return to file with EOF.
CTRL-Z | Suspend editor, resume with fg (not in all versions).
:so file | Read and execute commands from file.

Previous: 8.5 Accessing Multiple Files | UNIX in a Nutshell: System V Edition | Next: 8.7 Macros
8.5 Accessing Multiple Files | Book Index | 8.7 Macros


[Chapter 8] 8.7 Macros

Previous: 8.6 Interacting with UNIX Chapter 8
The Vi Editor 		Next: 8.8 Miscellaneous Commands

8.7 Macros

:ab in out |
Use in as abbreviation for out. :unab in | Remove abbreviation for in.
:ab | List abbreviations.
:map c sequence | Map character c as sequence of commands.
:unmap c | Disable map for character c.
:map | List characters that are mapped.
:map! c sequence | Map character c to input mode sequence.
:unmap! c | Disable input mode map (you may need to quote the character with CTRL-V).
:map! | List characters that are mapped to input mode.

The following characters are unused in command mode and can be mapped as user-defined commands.

Letters:

g K q V v

Control keys:

^A ^K ^O ^T ^W ^X

Symbols:

_ * \ =

(Note: The = is used by vi if Lisp mode is set.)

Previous: 8.6 Interacting with UNIX | UNIX in a Nutshell: System V Edition | Next: 8.8 Miscellaneous Commands
8.6 Interacting with UNIX | Book Index | 8.8 Miscellaneous Commands


[Chapter 8] 8.8 Miscellaneous Commands

Previous: 8.7 Macros Chapter 8
The Vi Editor 		Next: 8.9 Alphabetical List of Keys

8.8 Miscellaneous Commands

J | Join two lines.
:j! | Join two lines, preserving blank spaces.
<< | Shift this line left one shift width (default is 8 spaces).
>> | Shift this line right one shift width (default is 8 spaces).
>} | Shift right to end of paragraph.
<% | Shift left until matching parenthesis, brace, bracket, etc. (Cursor must be on the matching symbol.)

Previous: 8.7 Macros | UNIX in a Nutshell: System V Edition | Next: 8.9 Alphabetical List of Keys
8.7 Macros | Book Index | 8.9 Alphabetical List of Keys


[Chapter 8] 8.9 Alphabetical List of Keys

Previous: 8.8 Miscellaneous Commands Chapter 8
The Vi Editor 		Next: 8.10 Setting Up Vi

8.9 Alphabetical List of Keys

For brevity, control characters are marked by ^.

a | Append text after cursor.
A | Append text at end of line.
^A | Unused.
b | Back up to beginning of word in current line.
B | Back up to word, ignoring punctuation.
^B | Scroll backward one window.
c | Change operator.
C | Change to end of current line.
^C | Unused in command mode; ends insert mode.
d | Delete operator.
D | Delete to end of current line.
^D | Scroll down half-window.
e | Move to end of word.
E | Move to end of word, ignoring punctuation.
^E | Show one more line at bottom of window.
f | Find next character typed forward on current line.
F | Find next character typed backward on current line.
^F | Scroll forward one window.
g | Unused.
G | Go to specified line or end of file.
^G | Print information about file on status line.
h | Left arrow cursor key.
H | Move cursor to Home position.
^H | Left arrow cursor key; Backspace key in insert mode.
i | Insert text before cursor.
I | Insert text before first nonblank character on line.
^I | Unused in command mode; in insert mode, same as TAB key.
j | Down arrow cursor key.
J | Join two lines.
^J | Down arrow cursor key; in insert mode, move down a line.
k | Up arrow cursor key.
K | Unused.
^K | Unused.
l | Right arrow cursor key.
L | Move cursor to Last position in window.
^L | Redraw screen.
m | Mark the current cursor position in register (a-z).
M | Move cursor to Middle position in window.
^M | Carriage return.
n | Repeat the last search command.
N | Repeat the last search command in reverse direction.
^N | Down arrow cursor key.
o | Open line below current line.
O | Open line above current line.
^O | Unused.
p | Put yanked or deleted text after or below cursor.
P | Put yanked or deleted text before or above cursor.
^P | Up arrow cursor key.
q | Unused.
Q | Quit vi and invoke ex.
^Q | Unused (on some terminals, resume data flow).
r | Replace character at cursor with the next character you type.
R | Replace characters.
^R | Redraw the screen.
s | Change the character under the cursor to typed characters.
S | Change entire line.
^S | Unused (on some terminals, stop data flow).
t | Move cursor forward to character before next character typed.
T | Move cursor backward to character after next character typed.
^T | Unused in command mode; in insert mode, use if autoindent is set.
u | Undo the last change made.
U | Restore current line, discarding changes.
^U | Scroll the screen upward half-window.
v | Unused.
V | Unused.
^V | Unused in command mode; in insert mode, quote next character.
w | Move to beginning of next word.
W | Move to beginning of next word, ignoring punctuation.
^W | Unused in command mode; in insert mode, back up to beginning of word.
x | Delete character under cursor.
X | Delete character before cursor.
^X | Unused.
y | Yank or copy operator.
Y | Make copy of current line.
^Y | Show one more line at top of window.
z | Reposition line containing cursor. z must be followed either by: RETURN (reposition line to top of screen), . (reposition line to middle of screen), or - (reposition line to bottom of screen).
ZZ | Exit the editor, saving changes.
^Z | Suspend vi (only on systems that have job control).

Previous: 8.8 Miscellaneous Commands | UNIX in a Nutshell: System V Edition | Next: 8.10 Setting Up Vi
8.8 Miscellaneous Commands | Book Index | 8.10 Setting Up Vi


[Chapter 8] 8.10 Setting Up Vi

Previous: 8.9 Alphabetical List of Keys Chapter 8
The Vi Editor 		Next: 9. The Ex Editor

8.10 Setting Up Vi

This subsection describes the following:

  • The :set command

  • Options available with :set

  • Example .exrc file

8.10.1 The :set Command

The :set command allows you to specify options that change characteristics of your editing environment. Options may be put in the .exrc file or set during a vi session.

The colon should not be typed if the command is put in .exrc.

:set x | Enable option x.
:set nox | Disable option x.
:set x=val | Give value to optionx.
:set | Show changed options.
:set all | Show all options.
:set x? | Show value of option x.

8.10.2 Options Used by :set

The following table describes the options to :set. The first column includes the optional abbreviation, if there is one, and uses an equal sign to show that the option takes a value. The second column gives the default, and the third column describes the behavior of the enabled option.

Option | Default | Description
autoindent (ai) | noai | In insert mode, indent each line to the same level as the line above or below. Use with shiftwidth option.
autoprint (ap) | ap | Display changes after each editor command. (For global replacement, display last replacement.)
autowrite (aw) | noaw | Automatically write (save) file if changed before opening another file with :n or before giving UNIX command with :!.
beautify (bf) | nobf | Ignore all control characters during input (except tab, newline, or formfeed).
directory= (dir) | /tmp | Name the directory in which ex stores buffer files. (Directory must be writable.)
edcompatible | noed-compatible | Use ed-like features on substitute commands.
errorbells (eb) | errorbells | Sound bell when an error occurs.
exrc (ex) | noexrc | Allow the execution of .exrc files that reside outside the user's home directory.
hardtabs= (ht) | 8 | Define boundaries for terminal hardware tabs.
ignorecase (ic) | noic | Disregard case during a search.
lisp | nolisp | Insert indents in appropriate lisp format. ( ), { }, [[, and ]] are modified to have meaning for lisp.
list | nolist | Print tabs as ^I; mark ends of lines with $. (Use list to tell if end character is a tab or a space.)
magic | magic | Wildcard characters . (dot), * (asterisk), and [ ] (brackets) have special meaning in patterns.
mesg | mesg | Permit system messages to display on terminal while editing in vi.
number (nu) | nonu | Display line numbers on left of screen during editing session.
open | open | Allow entry to open mode from ex.
optimize (opt) | noopt | Abolish carriage returns at the end of lines when printing multiple lines, speeds output on dumb terminals when printing lines with leading white space (blanks or tabs).
paragraphs= (para> | IPLPPPQP LIpplpipbp | Define paragraph delimiters for movement by { or }. The pairs of characters in the value are the names of nroff/troff macros that begin paragraphs.
prompt | prompt | Display the ex prompt (:) when vi's Q command is given.
readonly (ro) | noro | Any writes (saves) of a file will fail unless you use ! after the write (works with w, ZZ, or autowrite).
redraw (re) | noredraw | Terminal redraws screen whenever edits are made (in other words, insert mode pushes over existing characters, and deleted lines immediately close up). Default depends on line speed and terminal type. noredraw is useful at slow speeds on a dumb terminal: deleted lines show up as , and inserted text appears to overwrite existing text until you press ESC.
remap | remap | Allow nested map sequences.
report= | 5 | Display a message on the prompt line whenever you make an edit that affects at least a certain number of lines. For example, 6dd reports the message "6 lines deleted."
scroll= | <1/2 window> | Amount of screen to scroll.
sections= (sect) | SHNHH HU | Define section delimiters for [[ ]] movement. The pairs of characters in the value are the names of nroff/troff macros that begin sections.
shell= (sh) | /bin/sh | Pathname of shell used for shell escape (:!) and shell command (:sh). Default value is derived from SHELL variable, which varies on different systems.
shiftwidth= (sw) | 8 | Define number of spaces in backward (^D) tabs when using the autoindent option.
showmatch (sm) | nosm | In vi, when ) or } is entered, cursor moves briefly to matching ( or {. (If match is not on the screen, rings the error message bell.) Very useful for programming.
showmode | noshowmode | In insert mode, displays a message on the prompt line indicating the type of insert you are making. For example, "Open Mode," or "Append Mode."
slowopen (slow) |  | Hold off display during insert. Default depends on line speed and terminal type.
tabstop= (ts) | 8 | Define number of spaces that a TAB indents during editing session. (Printer still uses system tab of 8.)
taglength= (tl) | 0 | Define number of characters that are significant for tags. Default (zero) means that all characters are significant.
tags= /usr/lib/tags | tags | Define pathname of files containing tags (see the UNIX ctags command.) By default, the system looks for files tags (in the current directory) and /usr/lib/tags.
term= |  | Set terminal type.
terse | noterse | Display shorter error messages.
timeout (to) | timeout | Keyboard maps "time out" after 1 second.
ttytype= |  | Set terminal type.
warn | warn | Display the message, "No write since last change."
window= (w) |  | Show a certain number of lines of the file on the screen. Default depends on line speed and terminal type.
wrapmargin= (wm) | 0 | Define right margin. If greater than zero, automatically inserts carriage returns to break lines.
wrapscan (ws) | ws | Searches wrap around either end of file.
writeany (wa) | nowa | Allow saving to any file.

8.10.3 Example .exrc File

set nowrapscan wrapmargin=7
set sections=SeAhBhChDh nomesg
map q :w^M:n^M
map v dwElp
ab ORA O'Reilly & Associates, Inc.

Previous: 8.9 Alphabetical List of Keys | UNIX in a Nutshell: System V Edition | Next: 9. The Ex Editor
8.9 Alphabetical List of Keys | Book Index | 9. The Ex Editor


[Chapter 9] The Ex Editor

Previous: 8.10 Setting Up Vi Chapter 9 Next: 9.2 Alphabetical Summary of Ex Commands

9. The Ex Editor

Contents:
Syntax of Ex Commands
Alphabetical Summary of Ex Commands

Ex is a line editor that serves as the foundation for the screen editor vi. Ex commands work on the current line or on a range of lines in a file. Most often, you use ex from within vi. In vi, ex commands are preceded by a colon and entered by pressing RETURN.

But you can invoke ex on its own-from the command line-just as you would invoke vi. (You could execute an ex script this way.) You can also use the vi command Q to quit the vi editor and enter ex.

This section presents the following topics:

  • Syntax of ex commands

  • Alphabetical summary of commands

For more information, see the Nutshell Handbook Learning the vi Editor.

9.1 Syntax of Ex Commands

To enter an ex command from vi, type:

:[address] command [options]

An initial : indicates an ex command. As you type the command, it is echoed on the status line. Enter the command by pressing RETURN. address is the line number or range of lines that are the object of command. options and addresses are described below. Ex commands are described in the alphabetical summary.

You can exit ex in several ways:

:x

Exit (save changes and quit).

:q!

Quit without saving changes.

:vi

Quit and enter the vi editor.

9.1.1 Options

!

Indicates a variant command form, overriding the normal behavior.

count

The number of times the command is to be repeated. Unlike in vi commands, count cannot precede the command, because a number preceding an ex command is treated as a line address. For example, d3 deletes three lines beginning with the current line; 3d deletes line 3.

file

The name of a file that is affected by the command. % stands for current file; # stands for previous file.

9.1.2 Addresses

If no address is given, the current line is the object of the command. If the address specifies a range of lines, the format is:

x,y

where x and y are the first and last addressed lines (x must precede y in the buffer). x and y may be a line number or a symbol. Using ; instead of , sets the current line to x before interpreting y. The notation 1,$ addresses all lines in the file, as does %.

9.1.3 Address Symbols

1,$ | All lines in the file.
% | All lines; same as 1,$.
x,y | Lines x through y.
x;y | Lines x through y, with current line reset to x.
0 | Top of file.
. | Current line.
n | Absolute line number n.
$ | Last line.
x-n | n lines before x.
x+n | n lines after x.
-[n] | One or n lines previous.
+[n] | One or n lines ahead.
'x | Line marked with x.
'' | Previous mark.
/pattern/ | Forward to line matching pattern.
?pattern? | Backward to line matching pattern.

See Section 6 for more information on using patterns.

Previous: 8.10 Setting Up Vi | UNIX in a Nutshell: System V Edition | Next: 9.2 Alphabetical Summary of Ex Commands
8.10 Setting Up Vi | Book Index | 9.2 Alphabetical Summary of Ex Commands


[Chapter 9] 9.2 Alphabetical Summary of Ex Commands

Previous: 9.1 Syntax of Ex Commands Chapter 9
The Ex Editor 		Next: 10. The Sed Editor

9.2 Alphabetical Summary of Ex Commands

Ex commands can be entered by specifying any unique abbreviation. In this listing, the full name appears in the margin, and the shortest possible abbreviation is used in the syntax line. Examples are assumed to be typed from vi, so they include the : prompt.

  • abbrev
  • append
  • args
  • change
  • copy
  • delete
  • edit
  • file
  • global
  • insert
  • join
  • k
  • list
  • map
  • mark
  • move
  • next
  • number
  • open
  • preserve
  • print
  • put
  • quit
  • read
  • read
  • recover
  • rewind
  • set
  • shell
  • source
  • substitute
  • t
  • tag
  • unabbreviate
  • undo
  • unmap
  • v
  • version
  • visual
  • visual
  • write
  • write
  • wq
  • xit
  • yank
  • z
  • !
  • =
  • < >
  • address
  • RETURN
  • &
  • ~

Previous: 9.1 Syntax of Ex Commands | UNIX in a Nutshell: System V Edition | Next: 10. The Sed Editor
9.1 Syntax of Ex Commands | Book Index | 10. The Sed Editor


[Chapter 10] The Sed Editor

Previous: 9.2 Alphabetical Summary of Ex Commands Chapter 10 Next: 10.2 Conceptual Overview

10. The Sed Editor

Contents:
Command-line Syntax
Conceptual Overview
Syntax of Sed Commands
Group Summary of Sed Commands
Alphabetical Summary of Sed Commands

This section presents the following topics:

  • Command-line syntax

  • Conceptual overview of sed

  • Syntax of sed commands

  • Group summary of sed commands

  • Alphabetical summary of sed commands

For more information, see the Nutshell Handbook sed & awk.

10.1 Command-line Syntax

The syntax for invoking sed has two forms:

sed [options] 'command' file(s)

sed [options] -f scriptfile file(s)

The first form allows you to specify an editing command on the command line, surrounded by single quotes. The second form allows you to specify a scriptfile, a file containing sed commands. If no files are specified, sed reads from standard input.

The following options are recognized:

-n

Suppress the default output; sed displays only those lines specified with the p command, or with the p flag of the s command.

-e cmd

Next argument is an editing command; not needed unless specifying two or more editing commands.

-f file

Next argument is a file containing editing commands.

Previous: 9.2 Alphabetical Summary of Ex Commands | UNIX in a Nutshell: System V Edition | Next: 10.2 Conceptual Overview
9.2 Alphabetical Summary of Ex Commands | Book Index | 10.2 Conceptual Overview


[Chapter 10] 10.2 Conceptual Overview

Previous: 10.1 Command-line Syntax Chapter 10
The Sed Editor 		Next: 10.3 Syntax of Sed Commands

10.2 Conceptual Overview

Sed is a non-interactive, or stream-oriented, editor. It interprets a script and performs the actions in the script. Sed is stream-oriented because, like many UNIX programs, input flows through the program and is directed to standard output. For example, sort is stream-oriented; vi is not. Sed's input typically comes from a file but can be directed from the keyboard. Output goes to the screen by default but can be captured in a file instead.

10.2.1 Typical Uses of Sed Include:

  • Editing one or more files automatically.

  • Simplifying repetitive edits to multiple files.

  • Writing conversion programs.

10.2.2 Sed Operates as Follows:

  • Each line of input is copied into a pattern space.

  • All editing commands in a sed script are applied in order to each line of input.

  • Editing commands are applied to all lines (globally) unless line addressing restricts the lines affected.

  • If a command changes the input, subsequent command-addresses will be applied to the current line in the pattern space, not the original input line.

  • The original input file is unchanged because the editing commands modify a copy of the original input line. The copy is sent to standard output (but can be redirected to a file).

Previous: 10.1 Command-line Syntax | UNIX in a Nutshell: System V Edition | Next: 10.3 Syntax of Sed Commands
10.1 Command-line Syntax | Book Index | 10.3 Syntax of Sed Commands


[Chapter 10] 10.3 Syntax of Sed Commands

Previous: 10.2 Conceptual Overview Chapter 10
The Sed Editor 		Next: 10.4 Group Summary of Sed Commands

10.3 Syntax of Sed Commands

Sed commands have the general form:

[address][,address][!]command [arguments]

Sed commands consist of addresses and editing commands. commands consist of a single letter or symbol; they are described later, alphabetically and by group. arguments include the label supplied to b or t, the filename supplied to r or w, and the substitution flags for s. addresses are described below.

10.3.1 Pattern Addressing

A sed command can specify zero, one, or two addresses. An address can be a line number, the symbol $ (for last line), or a regular expression enclosed in slashes (/pattern/). Regular expressions are described in Section 6. Additionally, \n can be used to match any newline in the pattern space (resulting from the N command), but not the newline at the end of the pattern space.

If the command specifies: | Then the command is applied to:
No address | Each input line
One address | Any line matching the address. Some commands accept only one address: a, i, r, q, and =.
Two comma-separated addresses | First matching line and all succeeding lines up to and including a line matching the second address.
An address followed by ! | All lines that do not match the address.

10.3.2 Examples

s/xx/yy/g | Substitute on all lines (all occurrences).
/BSD/d | Delete lines containing BSD.
/^BEGIN/,/^END/p | Print between BEGIN and END, inclusive.
/SAVE/!d | Delete any line that doesn't contain SAVE.
/BEGIN/,/END/!s/xx/yy/g | Substitute on all lines, except between BEGIN and END.

Braces ({}) are used in sed to nest one address inside another or to apply multiple commands at the same address.

[/pattern/][,/pattern/]{
command1
command2
}

The opening curly brace must end a line, and the closing curly brace must be on a line by itself. Be sure there are no blank spaces after the braces.

Previous: 10.2 Conceptual Overview | UNIX in a Nutshell: System V Edition | Next: 10.4 Group Summary of Sed Commands
10.2 Conceptual Overview | Book Index | 10.4 Group Summary of Sed Commands


[Chapter 10] 10.4 Group Summary of Sed Commands

Previous: 10.3 Syntax of Sed Commands Chapter 10
The Sed Editor 		Next: 10.5 Alphabetical Summary of Sed Commands

10.4 Group Summary of Sed Commands

In the lists below, the sed commands are grouped by function and are described tersely. Full descriptions, including syntax and examples, can be found afterward in the alphabetical summary.

10.4.1 Basic Editing

a\ | Append text after a line.
c\ | Replace text (usually a text block).
i\ | Insert text after a line.
d | Delete lines.
s | Make substitutions.
y | Translate characters (like a UNIX tr).

10.4.2 Line Information

= | Display line number of a line.
l | Display control characters in ASCII.
p | Display the line.

10.4.3 Input/Output Processing

n | Skip current line and go to line below.
r | Read another file's contents into the input.
w | Write input lines to another file.
q | Quit the sed script (no further output).

10.4.4 Yanking and Putting

h | Copy into hold space; wipe out what's there.
H | Copy into hold space; append to what's there.
g | Get the hold space back; wipe out the destination line.
G | Get the hold space back; append on line below.
x | Exchange contents of hold space and pattern space.

10.4.5 Branching Commands

b | Branch to label or to end of script.
t | Same as b, but branch only after substitution.
:label | Label branched to by t or b.

10.4.6 Multi-line Input Processing

N | Read another line of input (creates embedded newline).
D | Delete up to the embedded newline.
P | Print up to the embedded newline.

Previous: 10.3 Syntax of Sed Commands | UNIX in a Nutshell: System V Edition | Next: 10.5 Alphabetical Summary of Sed Commands
10.3 Syntax of Sed Commands | Book Index | 10.5 Alphabetical Summary of Sed Commands


[Chapter 10] 10.5 Alphabetical Summary of Sed Commands

Previous: 10.4 Group Summary of Sed Commands Chapter 10
The Sed Editor 		Next: 11. The Awk Scripting Language

10.5 Alphabetical Summary of Sed Commands

  • #
  • :
  • =
  • a
  • b
  • c
  • d
  • D
  • g
  • G
  • h
  • H
  • i
  • l
  • n
  • N
  • p
  • P
  • q
  • r
  • s
  • t
  • w
  • x
  • y

Previous: 10.4 Group Summary of Sed Commands | UNIX in a Nutshell: System V Edition | Next: 11. The Awk Scripting Language
10.4 Group Summary of Sed Commands | Book Index | 11. The Awk Scripting Language


[Chapter 11] The Awk Scripting Language

Previous: 10.5 Alphabetical Summary of Sed Commands Chapter 11 Next: 11.2 Conceptual Overview

11. The Awk Scripting Language

Contents:
Command-line Syntax
Conceptual Overview
Patterns and Procedures
Awk System Variables
Operators
Variables and Array Assignments
Group Listing of Awk Commands
Alphabetical Summary of Commands

This section presents the following topics:

  • Command-line syntax

  • Conceptual overview

  • Patterns and procedures

  • System variables

  • Operators

  • Variable and array assignment

  • Group listing of commands

  • Alphabetical summary of commands

For more information, see the Nutshell Handbook sed & awk.

11.1 Command-line Syntax

The syntax for invoking awk has two forms:

awk [options] 'script' var=value file(s)

awk [options] -f scriptfile var=value file(s)

You can specify a script directly on the command line, or you can store a script in a scriptfile and specify it with -f. Variables can be assigned a value on the command line. The value can be a literal, a shell variable ($name), or a command substitution (`cmd`), but the value is available only after a line of input is read (i.e., after the BEGIN statement). Awk operates on one or more files. If none is specified (or if - is specified), awk reads from the standard input.

The recognized options are:

-Fc

Set the field separator to character c. This is the same as setting the system variable FS. Nawk allows c to be a regular expression. Each input line, or record, is divided into fields by white space (blanks or tabs) or by some other user-definable record separator. Fields are referred to by the variables $1, $2,..., $n. $0 refers to the entire record.

-v var=value

Assign a value to variable var. This allows assignment before the script begins execution. (Available in nawk only.)

For example, to print the first three (colon-separated) fields on a separate line:

awk -F: '{print $1; print $2; print $3}' /etc/passwd

Numerous examples are shown later in this section under "Patterns and Procedures."

Previous: 10.5 Alphabetical Summary of Sed Commands | UNIX in a Nutshell: System V Edition | Next: 11.2 Conceptual Overview
10.5 Alphabetical Summary of Sed Commands | Book Index | 11.2 Conceptual Overview


[Chapter 11] 11.2 Conceptual Overview

Previous: 11.1 Command-line Syntax Chapter 11
The Awk Scripting Language 		Next: 11.3 Patterns and Procedures

11.2 Conceptual Overview

Awk is a pattern-matching program for processing files, especially when they are databases. The new version of awk, called nawk, provides additional capabilities and is now the standard in SVR4. Awk is still available under the same name (it is really just a link to the command oawk). In the next major release of System V, nawk will become the default. (The Free Software Foundation has a version of awk called gawk. All features in nawk are available in gawk.)

With original awk, you can:

  • Think of a text file as made up of records and fields in a textual database.

  • Use variables to change the database.

  • Perform arithmetic and string operations.

  • Use programming constructs such as loops and conditionals.

  • Produce formatted reports.

With nawk, you can also:

  • Define your own functions.

  • Execute UNIX commands from a script.

  • Process the result of UNIX commands.

  • Process command-line arguments more gracefully.

  • Work more easily with multiple input streams.

Previous: 11.1 Command-line Syntax | UNIX in a Nutshell: System V Edition | Next: 11.3 Patterns and Procedures
11.1 Command-line Syntax | Book Index | 11.3 Patterns and Procedures


[Chapter 11] 11.3 Patterns and Procedures

Previous: 11.2 Conceptual Overview Chapter 11
The Awk Scripting Language 		Next: 11.4 Awk System Variables

11.3 Patterns and Procedures

Awk scripts consist of patterns and procedures:

pattern {procedure}

Both are optional. If pattern is missing, {procedure} is applied to all lines. If {procedure} is missing, the matched line is printed.

11.3.1 Patterns

A pattern can be any of the following:

/regular expression/

relational expression

pattern-matching expression

BEGIN

END

  • Expressions can be composed of quoted strings, numbers, operators, functions, defined variables, or any of the predefined variables described later under "Awk System Variables".

  • Regular expressions use the extended set of metacharacters and are described in Section 6.

  • In addition, ^ and $ can be used to refer to the beginning and end of a field, respectively, rather than the beginning and end of a line.

  • Relational expressions use the relational operators listed under "Operators" later in this section. Comparisons can be either string or numeric. For example, $2 > $1 selects lines for which the second field is greater than the first.

  • Pattern-matching expressions use the operators ~ (match) and !~ (don't match). See "Operators" later in this section.

  • The BEGIN pattern lets you specify procedures that will take place before the first input line is processed. (Generally, you set global variables here.)

  • The END pattern lets you specify procedures that will take place after the last input record is read.

Except for BEGIN and END, patterns can be combined with the Boolean operators || (or), && (and), and ! (not). A range of lines can also be specified using comma-separated patterns:

pattern,pattern

11.3.2 Procedures

Procedures consist of one or more commands, functions, or variable assignments, separated by newlines or semicolons, and contained within curly braces. Commands fall into four groups:

  • Variable or array assignments

  • Printing commands

  • Built-in functions

  • Control-flow commands

11.3.3 Simple Pattern-Procedure Examples

  1. Print first field of each line:

    { print $1 }

  2. Print all lines that contain pattern:

    /pattern/

  3. Print first field of lines that contain pattern:

    /pattern/{ print $1 }

  4. Select records containing more than two fields:

    NF > 2

  5. Interpret input records as a group of lines up to a blank line:

    BEGIN { FS = "\n"; RS = "" }

  6. Print fields 2 and 3 in switched order, but only on lines whose first field matches the string "URGENT":

    $1 ~ /URGENT/ { print $3, $2 }

  7. Count and print the number of pattern found:

    /pattern/ { ++x }
END { print x }

  8. Add numbers in second column and print total:

    {total += $2 };
END { print "column total is", total}

  9. Print lines that contain less than 20 characters:

    length < 20

  10. Print each line that begins with Name: and that contains exactly seven fields:

    NF == 7 && /^Name:/

  11. Reverse the order of fields:

    { for (i = NF; i >= 1; i-) print $i }

Previous: 11.2 Conceptual Overview | UNIX in a Nutshell: System V Edition | Next: 11.4 Awk System Variables
11.2 Conceptual Overview | Book Index | 11.4 Awk System Variables


[Chapter 11] 11.4 Awk System Variables

Previous: 11.3 Patterns and Procedures Chapter 11
The Awk Scripting Language 		Next: 11.5 Operators

11.4 Awk System Variables

Version | Variable | Description
awk | FILENAME | Current filename.
 | FS | Field separator (default is a blank).
 | NF | Number of fields in current record.
 | NR | Number of the current record.
 | OFS | Output field separator (default is a blank).
 | ORS | Output record separator (default is a newline).
 | RS | Record separator (default is a newline).
 | $0 | Entire input record.
 | $n | nth field in current record; fields are separated by FS.
nawk | ARGC | Number of arguments on command line.
 | ARGV | An array containing the command-line arguments.
 | FNR | Like NR, but relative to the current file.
 | OFMT | Output format for numbers (default is %.6g).
 | RSTART | First position in the string matched by match function.
 | RLENGTH | Length of the string matched by match function.
 | SUBSEP | Separator character for array subscripts (default is \034).
gawk | ENVIRON | An associative array of environment variables.
 | IGNORECASE | An associative array of environment variables.

Previous: 11.3 Patterns and Procedures | UNIX in a Nutshell: System V Edition | Next: 11.5 Operators
11.3 Patterns and Procedures | Book Index | 11.5 Operators


[Chapter 11] 11.5 Operators

Previous: 11.4 Awk System Variables Chapter 11
The Awk Scripting Language 		Next: 11.6 Variables and Array Assignments

11.5 Operators

The table below lists the operators, in order of increasing precedence, that are available in awk.

Symbol | Meaning
= =+ -= *= /= %= ^= | Assignment.
?: | C conditional expression (nawk and gawk).
|| | Logical OR.
&& | Logical AND.
~ !~ | Match regular expression and negation.
< <= > >= != == | Relational operators.
(blank) | Concatenation.
+ - | Addition, subtraction.
* / % | Multiplication, division, and modulus.
+ - ! | Unary plus and minus, and logical negation.
^ | Exponentiation.
++ -- | Increment and decrement, either prefix or postfix.
$ | Field reference.

Previous: 11.4 Awk System Variables | UNIX in a Nutshell: System V Edition | Next: 11.6 Variables and Array Assignments
11.4 Awk System Variables | Book Index | 11.6 Variables and Array Assignments


[Chapter 11] 11.6 Variables and Array Assignments

Previous: 11.5 Operators Chapter 11
The Awk Scripting Language 		Next: 11.7 Group Listing of Awk Commands

11.6 Variables and Array Assignments

Variables can be assigned a value with an = sign. For example:

FS = ","

Expressions using the operators +, -, /, and % (modulo) can be assigned to variables.

Arrays can be created with the split function (see below), or they can simply be named in an assignment statement. ++, +=, and -= are used to increment or decrement an array, as in the C language. Array elements can be subscripted with numbers (array[1], ..., array[n]) or with names. For example, to count the number of occurrences of a pattern, you could use the following script:

/pattern/ { array["/pattern/"]++ }
END { print array["/pattern/"] }

Previous: 11.5 Operators | UNIX in a Nutshell: System V Edition | Next: 11.7 Group Listing of Awk Commands
11.5 Operators | Book Index | 11.7 Group Listing of Awk Commands


[Chapter 11] 11.7 Group Listing of Awk Commands

Previous: 11.6 Variables and Array Assignments Chapter 11
The Awk Scripting Language 		Next: 11.8 Alphabetical Summary of Commands

11.7 Group Listing of Awk Commands

Awk commands may be classified as follows:

Arithmetic Functions | String Functions | Control Flow Statements | Input/Output Processing | Miscellaneous
atan2* | gsub* | break | close* | delete*
cos | index | continue | getline* | function*
exp | length | do/while* | next* | system*
int | match* | exit | print |
log | split | for | printf |
rand* | sub* | if | sprintf |
sin | substr | return* |  |
sqrt | tolower [dagger] | while |  |
srand* | toupper [dagger] |  |  |

* Available in nawk [dagger] Available in gawk

Previous: 11.6 Variables and Array Assignments | UNIX in a Nutshell: System V Edition | Next: 11.8 Alphabetical Summary of Commands
11.6 Variables and Array Assignments | Book Index | 11.8 Alphabetical Summary of Commands


[Chapter 11] 11.8 Alphabetical Summary of Commands

Previous: 11.7 Group Listing of Awk Commands Chapter 11
The Awk Scripting Language 		Next: 12. Nroff and Troff

11.8 Alphabetical Summary of Commands

The following alphabetical list of statements and functions includes all that are available in awk, nawk, or gawk. Nawk includes all old awk commands, plus some additional commands (marked as {N}). Gawk includes all nawk commands, plus some additional commands (marked as {G}). Commands that aren't marked with a symbol are available in all versions.

  • atan2
  • break
  • close
  • continue
  • cos
  • delete
  • do
  • exit
  • exp
  • for
  • for
  • function
  • getline
  • gsub
  • if
  • index
  • int
  • length
  • log
  • match
  • next
  • print
  • printf
  • rand
  • return
  • sin
  • split
  • sprintf
  • sqrt
  • srand
  • sub
  • substr
  • system
  • tolower
  • toupper
  • while

Previous: 11.7 Group Listing of Awk Commands | UNIX in a Nutshell: System V Edition | Next: 12. Nroff and Troff
11.7 Group Listing of Awk Commands | Book Index | 12. Nroff and Troff


[Chapter 12] Nroff and Troff

Previous: 11.8 Alphabetical Summary of Commands Chapter 12 Next: 12.2 Command-line Invocation

12. Nroff and Troff

Contents:
Introduction
Command-line Invocation
Using the Requests: An Overview
Default Operation of Requests
Group Summary of Requests
Alphabetical Summary of Requests
Escape Sequences
Predefined Number Registers
Special Characters

This section presents the following topics:

  • Introduction

  • Command-line invocation

  • Using the requests: an overview

  • Default operation of requests

  • Group summary of requests

  • Alphabetical summary of requests

  • Escape sequences

  • Predefined number registers

  • Special characters

12.1 Introduction

Nroff and troff are UNIX programs for formatting text files. Nroff is designed to format output for line printers and letter-quality printers; you can also display the output on your screen. Troff is designed for typesetting. Except for some functions that are specific to typesetting, the same commands work for both programs.

Nroff and troff are not part of standard SVR4 but are included in the compatibility packages. It is this version that is documented here. Note, however, that some UNIX distributors include a vendor-specific version of nroff/troff. Various enhanced packages are also available, such as sqtroff from SoftQuad or groff from the Free Software Foundation. These packages might include additional requests or escape sequences. For completely accurate information, we recommend that you consult the text processing manuals that come with your specific UNIX implementation.

In addition, we make references to ditroff, or device-independent troff, which is a later version of troff. For the most part, ditroff works the same as troff; where there are distinctions, the original troff is referred to as otroff.

Previous: 11.8 Alphabetical Summary of Commands | UNIX in a Nutshell: System V Edition | Next: 12.2 Command-line Invocation
11.8 Alphabetical Summary of Commands | Book Index | 12.2 Command-line Invocation


[Chapter 12] 12.2 Command-line Invocation

Previous: 12.1 Introduction Chapter 12
Nroff and Troff 		Next: 12.3 Using the Requests: An Overview

12.2 Command-line Invocation

Nroff and troff are invoked from the command line as follows:

/usr/ucb/nroff [options] [files]

/usr/ucb/troff [options] [files]

Many of the options are the same for both formatters.

Nroff/troff options

-Fdir

Search for font tables in directory dir.

-i

Read standard input after files are processed.

-mname

Prepend a macro file to input files. Troff prepends /usr/lib/tmac/tmac.name. Nroff prepends /usr/share/lib/tmac/tmac.name.

-nN

First output page has page number N.

-olist

Print pages contained only in the comma-separated list. Page ranges can be specified as n-m, -m (first page through m), or n- (n through end of file).

-raN

Set register a to N.

-sN

Stop every n pages. This allows changing of a paper cassette. Resume by pressing RETURN (in nroff) or by pressing the start button on the typesetter (in troff).

-Tname

Prepare output designed for printer or typesetter name. For device names, see your specific documentation or a local expert.

-uN

The font in position 3 is overstruck N times. Typically used to adjust the weight of the bold font.

-z

Discard output except messages generated by .tm request.

Nroff-only options

-e

When justifying output lines, space words equally (using terminal resolution instead of full space increments).

-h

Hasten output by replacing 8 horizontal spaces with a tab.

-q

Invoke simultaneous input/output of .rd requests.

Troff-only options

-a

Format a printable ASCII approximation. Useful for finding page counts without producing printed output.

-f

Don't stop typesetter when formatting is done.

Examples

Run chap1 through the tbl preprocessor, then format the result using the mm macros, with register N set to 5 (sets the page-numbering style), etc.:

tbl chap1 | troff -mm -rN5 | spooler &

Format chap2 using the ms macros; the first page is 7, but print only pages 8-10, 15, and 18 through the end of the file:

nroff -ms -n7 -o8-10,15,18- chap2 &

Previous: 12.1 Introduction | UNIX in a Nutshell: System V Edition | Next: 12.3 Using the Requests: An Overview
12.1 Introduction | Book Index | 12.3 Using the Requests: An Overview


[Chapter 12] 12.3 Using the Requests: An Overview

Previous: 12.2 Command-line Invocation Chapter 12
Nroff and Troff 		Next: 12.4 Default Operation of Requests

12.3 Using the Requests: An Overview

Formatting is specified by embedding brief codes into the text source file. These codes act as directives to nroff and troff when they are invoked. For example, to center a line of text, type the following code in a file:

 .ce
This text should be centered.

When formatted, the output appears centered:

 .ce
This text should be centered.

There are two types of formatting codes:

  • Requests, which provide the most elementary instructions, and

  • Macros, which are predefined combinations of requests.

Requests, also known as primitives, allow direct control of almost any feature of page layout and formatting. Macros combine requests to create a total effect. In a sense, requests are like atoms, and macros are like molecules.

See Sections 13, 14, and 15 for more information on macros.

12.3.1 Common Requests

The most commonly used requests are:

 .ad   .ds   .ll   .nr   .sp
 .br   .fi   .na   .po   .ta
 .bp   .ft   .ne   .ps   .ti
 .ce   .in   .nf   .so   .vs
 .de   .ls

For example, a simple macro could be written as follows:

.ta 1.2i
.	\" Ps macro - show literal text display
.de Ps	\" Define a macro named "Ps"
.sp .5	\" Space down half a line
.in 1i	\" Indent one inch
.ta 10n +10n	\" Set new tabstops
.ps 8	\" Use 8-point type
.vs 10	\" Use 10-point vertical spacing
.ft CW	\" Use constant width font
.br		\" Break line (.ne begins count on next line)
.ne 3	\" Keep 3 lines together
.nf	\" No-fill mode (output lines as is)
..	\" End macro definition

12.3.2 Specifying Measurements

With some requests, the numeric argument can be followed by a scale indicator that specifies a unit of measurement. The valid indicators and their meanings are listed below. Note that all measurements are internally converted to basic units (this conversion is shown in the last column). A basic unit is the smallest possible size on the printer device. The device resolution (e.g., 300 dots per inch), determines the size of a basic unit. In the following table, T specifies the current point size and R specifies the device resolution.

Scale | Meaning | Equivalent | Number of
Indicator |  | Unit | Basic Units
c | Centimeter | 2.54 inches | R / 2.54
i | Inch | 6 picas or 72 points | R
m | Em | T points | R × T / 72
n | En | 0.5 em | R × T / 144
p | Point | 1/72 inch | R / 72
P | Pica | 1/6 inch | R / 6
u | Basic unit |  | 1
v | Vertical line space |  | (Current value in basic units)
None | Default |  |

You can specify a scale indicator for any of the requests below, except for .ps, which always uses points. If no unit is given, the default unit is used. (The second column lists the scale indicators as described in the previous table.) For horizontally oriented requests, the default unit is ems. For vertically oriented requests, the default is usually vertical lines.

Request | Default | Request | Default
 | Scale |  | Scale
.ch | v | .pl | v
.dt | v | .po | v
.ie | u | .ps | p
.if | u | .rt | v
.in | m | .sp | v
.ll | m | .sv | v
.lt | m | .ta | m
.mc | m | .ti | m
.ne | v | .vs | p
.nr | u | .wh | v

12.3.3 Requests That Cause a Line Break

Most requests can be interspersed with text without causing a line break in the output. The following requests cause a break:

.bp   .ce   .fi   .in   .sp
.br   .cf   .fl   .nf   .ti

If you need to prevent these requests from causing a break, begin them with the "no break" character (normally ') instead of a dot (.). For example, .sp takes effect right away, but 'sp waits until the output line is completely filled. Only then does it add a line space.

Previous: 12.2 Command-line Invocation | UNIX in a Nutshell: System V Edition | Next: 12.4 Default Operation of Requests
12.2 Command-line Invocation | Book Index | 12.4 Default Operation of Requests


[Chapter 12] 12.4 Default Operation of Requests

Previous: 12.3 Using the Requests: An Overview Chapter 12
Nroff and Troff 		Next: 12.5 Group Summary of Requests

12.4 Default Operation of Requests

Nroff/troff initializes the formatting environment. For example, unless you reset the line length, nroff/troff uses 6.5 inches. Most requests can change the default environment, and those that can are listed in the table below. The second column lists the initial or default value in effect before the request is used. If no initial value applies, a hyphen (-) is used. The third column shows the effect if a request's optional argument is not used. Here, a hyphen is used if the request doesn't accept an argument or if the argument is required.

Request | Initial | If No | Description
 | Value | Argument |
.ad | Justify | Previous adjust | Adjust margins.
.af | Lowercase arabic | - | Assign a format to a register.
.am | - | End call with .. | Append to a macro.
.bd | Off | - | Embolden font.
.c2 | ; | ; | Set no-break control character.
.cc | . | . | Set control character.
.ce | Off | Center one line | Center lines.
.ch | - | Turn off trap | Change trap position.
.cs | Off | - | Set constant-width spacing.
.cu | 0 | 1 line | Continuous underline/italicize.
.da | - | End the diversion | Divert text and append to a macro.
.de | - | End macro with .. | Define a macro.
.di | - | End the diversion | Divert text to a macro.
.dt | - | Turn off trap | Set a diversion trap.
.ec | \ | \ | Set escape character.
.eo | On | - | Turn off escape character.
.ev | 0 | Prev. environment | Change environment.
.fc | Off | Off | Set field delimiter and pad character.
.fi | Fill | - | Fill lines.
.fp | 1 = R | - | Mount font (on positions 1-4).
 | 2 = I |  |
 | 3 = B |  |
 | 4 = S |  |
.ft | Roman | Previous font | Set font.
.hc | \% | \% | Set hyphenation character.
.hy | Mode 1 | Previous mode | Set hyphenation mode.
.ig | - | End with .. | Suppress (ignore) text in output.
.in | 0 | Previous indent | Indent.
.it | - | Turn off trap | Set a trap for input line counting.
.lc | . | None | Set leader character.
.lg | On | On | Ligature mode.
.ll | 6.5" | Prev. line length | Set line length.
.ls | Single-space | Previous mode | Set line spacing.
.lt | 6.5" | Prev. title length | Set length of title.
.mc | - | Turn off | Set the margin character.
.mk | - | Internal | Mark vertical position.
.na | Adjust | - | Don't adjust margins.
.ne | - | One vertical line | Keep lines on same page if there's room.
.nf | Fill | - | Don't fill lines.
.nh | On | - | Turn of hyphenation.
.nm | Off | Off | Line-numbering mode.
.nn | - | Number one line | Don't number lines.
.ns | Space mode | - | Enable no-space mode.
.nx | - | End of file | Go to a file.
.pc | % | Off | Set page character.
.pl | 11" | 11" | Set page length.
.pn | Page 1 | - | Set page number.
.po | 0 (nroff) | Previous offset | Change page offset.
 | 26/27" (troff) |  |
.ps | 10 | Prev. point size | Set point size.
.rd | - | Ring bell | Read from the terminal.
.rt | - | Internal | Return to marked vertical place.
.sp | - | One vertical line | Output blank spacing.
.ss | 12/36 em | - | Set character spacing.
.sv | - | One vertical line | Save (store) spacing.
.ta | .5" (troff) | - | Define tab settings.
 | 8 em (nroff) |  |
.ti | 0 | - | Indent next line.
.tm | - | Newline | Print a message, then continue.
.uf | Italic | Italic | Set font for underlining.
.ul | 0 | 1 line | Underline/italicize.
.vs | 1/6" (nroff) | Previous value | Set vertical spacing for lines.
 | 12 pts (troff) |  |

Previous: 12.3 Using the Requests: An Overview | UNIX in a Nutshell: System V Edition | Next: 12.5 Group Summary of Requests
12.3 Using the Requests: An Overview | Book Index | 12.5 Group Summary of Requests


[Chapter 12] 12.5 Group Summary of Requests

Previous: 12.4 Default Operation of Requests Chapter 12
Nroff and Troff 		Next: 12.6 Alphabetical Summary of Requests

12.5 Group Summary of Requests

As an aid to finding the right request for a particular task, the 84 nroff/troff requests are listed below by subject:

12.5.1 Character Output

.cu | Continuous underline/italicize.
.lg | Ligature mode.
.tr | Translate characters.
.uf | Set font for underlining.
.ul | Underline/italicize.

12.5.2 Conditional Processing

.el | Else portion of if-else.
.ie | If portion of if-else.
.if | If statement.

12.5.3 Customizing Troff/Nroff Requests

.c2 | Set no-break control character.
.cc | Set control character.
.ec | Set escape character.
.eo | Turn off escape character.
.hc | Set hyphenation character.
.pc | Set page character.

12.5.4 Diagnostic Output

.ab | Print a message, then abort.
.fl | Flush output buffer.
.ig | Suppress (ignore) text in output.
.mc | Set the margin character.
.pm | Print name and size of macros.
.tm | Print a message, then continue.

12.5.5 Font and Character Size

.bd | Embolden font.
.cs | Set constant-width spacing.
.fp | Mount font (on positions 1-4).
.ft | Set font.
.ps | Set point size.
.ss | Set character spacing.

12.5.6 Horizontal Positioning

.in | Indent.
.ll | Set line length.
.lt | Set length of title.
.po | Change page offset.
.ti | Indent next line.
.tl | Specify three-part title.

12.5.7 Hyphenation

.hw | Set hard-coded hyphenation.
.hy | Set hyphenation mode.
.nh | Turn of hyphenation.

12.5.8 Input/Output Switching

.cf | Copy raw file to output.
.ex | Exit from nroff/troff.
.nx | Go to a file.
.pi | Pipe output to a UNIX command.
.rd | Read from the terminal.
.so | Go to a file, then return.
.sy | Execute a UNIX command.

12.5.9 Line Numbering

.nm | Line-numbering mode.
.nn | Don't number lines.

12.5.10 Macro and String Processing

.am | Append to a macro.
.as | Append to a string.
.ch | Change trap position.
.da | Divert text; append to a macro.
.de | Define a macro.
.di | Divert text to a macro.
.ds | Define a string.
.dt | Set a diversion trap.
.em | Set the ending macro.
.ev | Change environment.
.it | Set trap for input line counting.
.rm | Remove macro, request, or string.
.rn | Rename macro, request, or string.
.wh | Set a page trap.

12.5.11 Number Registers

.af | Assign a format to a register.
.nr | Define a number register.
.rr | Remove a number register.

12.5.12 Pagination

.bp | Begin a new page.
.mk | Mark vertical position.
.ne | Keep lines on same page if there's room.
.pl | Set page length.
.pn | Set page number.
.rt | Return to marked vertical place.

12.5.13 Tabs

.fc | Set a field delimiter and a pad character.
.lc | Set leader character.
.ta | Define tab settings.
.tc | Set tab character.

12.5.14 Text Adjustments

.ad | Adjust margins.
.br | Break the output line.
.ce | Center lines.
.fi | Fill lines.
.na | Don't adjust margins.
.nf | Don't fill lines.

12.5.15 Vertical Spacing

.ls | Line spacing (e.g., single-spaced).
.ns | Enable no-space mode.
.os | Output vertical space from .sv.
.rs | Restore spacing mode.
.sp | Output blank spacing.
.sv | Save (store) spacing.
.vs | Set vertical spacing for lines.

Previous: 12.4 Default Operation of Requests | UNIX in a Nutshell: System V Edition | Next: 12.6 Alphabetical Summary of Requests
12.4 Default Operation of Requests | Book Index | 12.6 Alphabetical Summary of Requests


[Chapter 12] 12.6 Alphabetical Summary of Requests

Previous: 12.5 Group Summary of Requests Chapter 12
Nroff and Troff 		Next: 12.7 Escape Sequences

12.6 Alphabetical Summary of Requests

  • .ab
  • .ad
  • .af
  • .am
  • .as
  • .bd
  • .bp
  • .br
  • .c2
  • .cc
  • .ce
  • .cf
  • .ch
  • .cs
  • .cu
  • .da
  • .de
  • .di
  • .ds
  • .dt
  • .ec
  • .el
  • .em
  • .eo
  • .ev
  • .ex
  • .fc
  • .fi
  • .fl
  • .fp
  • .ft
  • .hc
  • .hw
  • .hy
  • .ie
  • .if
  • .ig
  • .in
  • .it
  • .lc
  • .lg
  • .ll
  • .ls
  • .lt
  • .mc
  • .mk
  • .na
  • .ne
  • .nf
  • .nh
  • .nm
  • .nn
  • .nr
  • .ns
  • .nx
  • .os
  • .pc
  • .pi
  • .pl
  • .pm
  • .pn
  • .po
  • .ps
  • .rd
  • .rm
  • .rn
  • .rr
  • .rs
  • .rt
  • .so
  • .sp
  • .ss
  • .sv
  • .sy
  • .ta
  • .tc
  • .ti
  • .tl
  • .tm
  • .tr
  • .uf
  • .ul
  • .vs
  • .wh

Previous: 12.5 Group Summary of Requests | UNIX in a Nutshell: System V Edition | Next: 12.7 Escape Sequences
12.5 Group Summary of Requests | Book Index | 12.7 Escape Sequences


[Chapter 12] 12.7 Escape Sequences

Previous: 12.6 Alphabetical Summary of Requests Chapter 12
Nroff and Troff 		Next: 12.8 Predefined Number Registers

12.7 Escape Sequences

Sequence | Effect
\\ | Prevent or delay the interpretation of \.
\e | Printable version of the current \ escape character.
\' | ´ (acute accent); equivalent to \(aa.
\` | ` (grave accent); equivalent to \(ga.
\- | - Minus sign in the current font.
\. | Period (dot).
\(space) | Unpaddable space-size space character.
\(newline) | Concealed (ignored) newline.
\0 | Digit width space.
\| | 1/6-em narrow space character (zero width in nroff).
\^ | 1/12-em half-narrow space character (zero width in nroff).
\& | Non-printing, zero width character.
\! | Transparent line indicator.
\" | Beginning of comment.
\$n | Interpolate argument 1 [image] n [image] 9.
\% | Default optional hyphenation character.
\(xx | Character named xx.
\*x or \*(xx | Interpolate string x or xx.
\a | Noninterpreted leader character.
\b'abc...' | Bracket building function.
\c | Make next line continuous with current.
\d | Forward (down) 1/2-em vertical motion (1/2 line in nroff).
\D'l x,y' | Draw a line from current position to coordinates x,y (ditroff only).
\D'c d' | Draw circle of diameter d with left edge at current position (ditroff only).
\D'e d1 d2' | Draw ellipse with horizontal diameter d1 and vertical diameter d2, with left edge at current position (ditroff only).
\D'a x1 y1 x2 y2' | Draw arc counterclockwise from current position, with center at x1,y1 and endpoint at x1+x2,y1+y2 (ditroff only).
\D'~ x1 y1 x2 y2...' | Draw spline from current position through the specified coordinates (ditroff only).
\fx or \f(xx or \fn | Change to font named x or xx or to position n.
\h'n' | Local horizontal motion; move right n or if n is negative move left.
\H'n' | Set character height to n points, without changing width (ditroff only).
\kx | Mark horizontal input place in register x.
\l'nc' | Draw horizontal line of length n (optionally with c).
\L'nc' | Draw vertical line of length n (optionally with c).
\nx\,\n(xx | Interpolate number register x or xx.
\o'abc...' | Overstrike characters a, b, c...
\p | Break and spread output line.
\r | Reverse 1-em vertical motion (reverse line in nroff).
\sn\,\s±n | Change point-size to n or increment by n. For example, \s0 returns to previous point size.
\S'n' | Slant output n degrees to the right. Negative values slant to the left. A value of zero turns off slanting (ditroff only).
\t | Non-interpreted horizontal tab.
\u | Reverse (up) 1/2-em vertical motion (1/2 line in nroff).
\v'n' | Local vertical motion; move down n or if n is negative move up.
\w'string' | Interpolate width of string.
\x'n' | Extra line-space function (n negative provides space before, n positive provides after).
\zc | Print c with zero width (without spacing).
\{ | Begin multi-line conditional input.
\} | End multi-line conditional input.
\x | x, any character not listed above.

Previous: 12.6 Alphabetical Summary of Requests | UNIX in a Nutshell: System V Edition | Next: 12.8 Predefined Number Registers
12.6 Alphabetical Summary of Requests | Book Index | 12.8 Predefined Number Registers


[Chapter 12] 12.8 Predefined Number Registers

Previous: 12.7 Escape Sequences Chapter 12
Nroff and Troff 		Next: 12.9 Special Characters

12.8 Predefined Number Registers

There are two types of predefined registers: read-only and read-write.

12.8.1 Read-only Registers

.$ | Number of arguments available at the current macro level.
.$$ | Process id of troff process (ditroff only).
.A | Set to 1 in troff, if -a option used; always 1 in nroff.
.H | Available horizontal resolution in basic units.
.T | Set to 1 in nroff, if -T option used; always 0 in troff; in ditroff, the string \*(.T contains the value of -T.
.V | Available vertical resolution in basic units.
.a | Post-line extra line-space most recently utilized using \x'n'.
.c | Number of lines read from current input file.
.d | Current vertical place in current diversion; equal to register nl when there is no diversion.
.f | Current font as physical quadrant (1 to 4 in otroff; 1 to 9 in ditroff).
.h | Text baseline high-water mark on current page or diversion.
.i | Current indent.
.j | Current adjustment mode.
.l | Current line length.
.n | Length of text portion on previous output line.
.o | Current page offset.
.p | Current page length.
.s | Current point size.
.t | Distance to the next trap.
.u | Equal to 1 in fill mode and 0 in no-fill mode.
.v | Current vertical line spacing.
.w | Width of previous character.
.x | Reserved version-dependent register.
.y | Reserved version-dependent register.
.z | Name of current diversion.

12.8.2 Read-write Registers

% | Current page number.
ct | Character type (set by width function).
dl | Width (maximum) of last completed diversion.
dn | Height (vertical size) of last completed diversion.
dw | Current day of the week (1 to 7).
dy | Current day of the month (1 to 31).
hp | Current horizontal place on input line.
ln | Output line number.
mo | Current month (1 to 12).
nl | Vertical position of last printed text baseline.
sb | Depth of string below baseline (generated by width function).
st | Height of string above base line (generated by width function).
yr | Last two digits of current year.

Previous: 12.7 Escape Sequences | UNIX in a Nutshell: System V Edition | Next: 12.9 Special Characters
12.7 Escape Sequences | Book Index | 12.9 Special Characters


[Chapter 12] 12.9 Special Characters

Previous: 12.8 Predefined Number Registers Chapter 12
Nroff and Troff 		Next: 13. mm Macros

12.9 Special Characters

This subsection lists the following special characters:

  • Characters that reside on the standard fonts

  • Miscellaneous characters

  • Bracket building symbols

  • Mathematics symbols

  • Greek characters

The characters in the first table below are available on the standard fonts. The characters in the remaining tables are available only on the special font.

Table 12.1: On the Standard Fonts
Char | Input | Character Name
' | ' | Close quote
` | ` | Open quote
- | \(em | 3\4 em dash
- | - | Hyphen or
- | \(hy | Hyphen
- | \- | Minus in current font
· | \(bu | Bullet
 | \(sq | Square
_ | \(ru | Rule
¼ | \(14 | 1/4
½ | \(12 | 1/2
¾ | \(34 | 3/4
fi | \(fi | fi ligature
fl | \(fl | fl ligature
ff | \(ff | ff ligature
ffi | \(Fi | ffi ligature
ffl | \(Fl | ffl ligature
° | \(de | Degree
[dagger] | \(dg | Dagger
' | \(fm | Foot mark
¢ | \(ct | Cent sign
® | \(rg | Registered
© | \(co | Copyright
Table 12.2: Miscellaneous Characters
Char | Input | Character Name
§ | \(sc | Section
´ | \(aa | Acute accent
` | \(ga | Grave accent
_ | \(ul | Underrule
-> | \(-> | Right arrow
<- | \(<- | Left arrow
 | \(ua | Up arrow
-v | \(da | Down arrow
| | \(br | Box rule
[dbldag] | \(dd | Double dagger
[rhand] | \(rh | Right hand
[lhand] | \(lh | Left hand
[circle] | \(ci | Circle
(+) | \(vs | Visible space indicator (ditroff only)
Table 12.3: Bracket Building Symbols
Char | Input | Character Name
[ltbcb] | \(lt | Left top of big curly bracket
[lcbcb] | \(lk | Left center of big curly bracket
[lbbcb] | \(lb | Left bottom of big curly bracket
[rtbcb] | \(rt | Right top of big curly bracket
[rcbcb] | \(rk | Right center of big curly bracket
[rbbcb] | \(rb | Right bottom of big curly bracket
[ | \(lc | Left ceiling (left top) of big square bracket
| | \(bv | Bold vertical
[ | \(lf | Left floor left bottom of big square bracket
] | \(rc | Right ceiling (right top) of big square bracket
] | \(rf | Right floor (right bottom) of big square bracket
Table 12.4: Mathematics Symbols
Char | Input | Character Name
+ | \(pl | Math plus
- | \(mi | Math minus
= | \(eq | Math equals
* | \(** | Math star
/ | \(sl | Slash (matching backslash)
[v/] | \(sr | Square root
 | \(rn | Root en extender
 | \(>= | Greater than or equal to
 | \(<= | Less than or equal to
 | \(== | Identically equal
~ | \(~~ | Approx equal
~ | \(ap | Approximates
 | \(!= | Not equal
× | \(mu | Multiply
÷ | \(di | Divide
± | \(+- | Plus-minus
U | \(cu | Cup (union)
[cap] | \(ca | Cap (intersection)
[subset] | \(sb | Subset of
[superset] | \(sp | Superset of
[subset/equal] | \(ib | Improper subset
[superset/equal] | \(ip | Improper superset
[infinity] | \(if | Infinity
d | \(pd | Partial derivative
[nabla] | \(gr | Gradient
¬ | \(no | Not
[integral] | \(is | Integral sign
[proportional] | \(pt | Proportional to
Ø | \(es | Empty set
[isin] | \(mo | Member of
| | \(or | Or

12.9.1 Greek Characters

Characters that have equivalents as uppercase English letters are available on the standard fonts; otherwise, the characters below exist only on the special font.

Char | Input | Char Name | Char | Input | Char Name
[alpha] | \(*a | alpha | A | \(*A | ALPHA
[beta] | \(*b | beta | B | \(*B | BETA
[gamma] | \(*g | gamma | [Gamma] | \(*G | GAMMA
[delta] | \(*d | delta | [delta] | \(*D | DELTA
[epsilon] | \(*e | epsilon | E | \(*E | EPSILON
[zeta] | \(*z | zeta | Z | \(*Z | ZETA
[eta] | \(*y | eta | H | \(*Y | ETA
[theta] | \(*h | theta | [Theta] | \(*H | THETA
[iota] | \(*i | iota | I | \(*I | IOTA
[kappa] | \(*k | kappa | K | \(*K | KAPPA
[lambda] | \(*l | lambda | [Lambda] | \(*L | LAMBDA
[mu] | \(*m | mu | M | \(*M | MU
[nu] | \(*n | nu | N | \(*N | NU
[xi] | \(*c | xi | [Xi] | \(*C | XI
[omicron] | \(*o | omicron | O | \(*O | OMICRON
[pi] | \(*p | pi | [Pi] | \(*P | PI
[rho] | \(*r | rho | P | \(*R | RHO
[sigma] | \(*s | sigma | [Sigma] | \(*S | SIGMA
[sigma] | \(ts | terminal sigma |  |  |
[tau] | \(*t | tau | T | \(*T | TAU
[upsilon] | \(*u | upsilon | [Upsilon] | \(*U | UPSILON
[phi] | \(*f | phi | [Phi] | \(*F | PHI
[chi] | \(*x | chi | X | \(*X | CHI
[psi] | \(*q | psi | [Psi] | \(*Q | PSI
[omega] | \(*w | omega | [Omega] | \(*W | OMEGA

Previous: 12.8 Predefined Number Registers | UNIX in a Nutshell: System V Edition | Next: 13. mm Macros
12.8 Predefined Number Registers | Book Index | 13. mm Macros


[Chapter 13] mm Macros

Previous: 12.9 Special Characters Chapter 13 Next: 13.2 Predefined String Names

13. mm Macros

Contents:
Alphabetical Summary of mm Macros
Predefined String Names
Number Registers Used in mm
Other Reserved Macro and String Names

This section presents the following topics:

  • Alphabetical summary of mm macros

  • Predefined string names

  • Number registers

  • Other reserved names

13.1 Alphabetical Summary of mm Macros

  • .1C
  • .2C
  • .AE
  • .AF
  • .AL
  • .AS
  • .AT
  • .AU
  • .AV
  • .B
  • .BE
  • .BI
  • .BL
  • .BR
  • .BS
  • .CS
  • .DE
  • .DF
  • .DL
  • .DS
  • .EC
  • .EF
  • .EH
  • .EN
  • .EQ
  • .EX
  • .FC
  • .FD
  • FE
  • .FG
  • .FS
  • .H
  • .HC
  • .HM
  • .HU
  • .HX
  • .HY
  • .HZ
  • .I
  • .IA
  • .IB
  • .IE
  • .IR
  • .LB
  • .LC
  • .LE
  • .LI
  • .LO
  • .LT
  • .ML
  • .MT
  • .ND
  • .NE
  • .nP
  • .NS
  • .OF
  • .OH
  • .OK
  • .OP
  • .P
  • .PF
  • .PH
  • .PM
  • .PX
  • .R
  • .RB
  • .RD
  • .RF
  • .RI
  • .RL
  • .RP
  • .RS
  • .S
  • .SA
  • .SG
  • .SK
  • .SM
  • .SP
  • .TB
  • .TC
  • .TE
  • .TH
  • .TL
  • .TM
  • .TP
  • .TS
  • .TX
  • .TY
  • .VL
  • .VM
  • .WA
  • .WE
  • .WC

Previous: 12.9 Special Characters | UNIX in a Nutshell: System V Edition | Next: 13.2 Predefined String Names
12.9 Special Characters | Book Index | 13.2 Predefined String Names


[Chapter 13] 13.2 Predefined String Names

Previous: 13.1 Alphabetical Summary of mm Macros Chapter 13
mm Macros 		Next: 13.3 Number Registers Used in mm

13.2 Predefined String Names

BU | Bullet; same as \(bu.
Ci | List of indents for table of contents levels.
DT | Current date, unless overridden. Month, day, year (e.g., July 28, 1986).
EM | Em dash string - dash in troff and a double hyphen in nroff).
F | Footnote number generator.
HF | Fonts used for each level of heading (1 = roman, 2 = italic, 3 = bold).
HP | Point size used for each level of heading.
Le | Title set for ``List Of Equations."
Lf | Title set for ``List Of Figures."
Lt | Title set for ``List Of Tables."
Lx | Title set for ``List Of Exhibits."
RE | SCCS release and level of mm.
Rf | Reference number generator.
Rp | Title for ``References."
TM | Trademark string. Places the letters ``TM" one-half line above the text that it follows.

Previous: 13.1 Alphabetical Summary of mm Macros | UNIX in a Nutshell: System V Edition | Next: 13.3 Number Registers Used in mm
13.1 Alphabetical Summary of mm Macros | Book Index | 13.3 Number Registers Used in mm


[Chapter 13] 13.3 Number Registers Used in mm

Previous: 13.2 Predefined String Names Chapter 13
mm Macros 		Next: 13.4 Other Reserved Macro and String Names

13.3 Number Registers Used in mm

A dagger ( [dagger]) next to a register name indicates that the register can be set only from the command line or before the mm macro definitions are read by the formatter. Any register having a single-character name can be set from the command line with the -r option.

A [dagger]

If set to 1, omit technical memorandum headings and provide spaces appropriate for letterhead (see .AF macro).

Au | Omit author information on first page (see .AU macro).
C [dagger] | Flag indicating type of copy (original, draft, etc.).
Cl

Level of headings saved for table of contents (see .TC macro). Default is 2.

Cp

If set to 1 (default), list of figures and tables appear on same page as table of contents. Otherwise, they start on a new page.

D [dagger]

If set to 1, use debug mode (mm continues even after encountering normally fatal errors). Default is 0.

De | If set to 1, eject page after each floating display. Default is 0.
Df | Set format of floating displays (see .DF macro).
Ds | Set space used before and after static displays.
E [dagger] | Font for Subject/Date/From. 0 (bold, the default) or 1 (roman).
Ec | Equation counter, incremented for each .EC macro.
Ej | Heading level for page eject before headings. Default is 0 and no eject.
Eq | If set to 1, place equation label at left margin. Default is 0.
Ex | Exhibit counter, incremented for each .EX macro.
Fg | Figure counter, incremented for each .FG macro.
Fs | Vertical spacing between footnotes.
Hn

Heading counter for level n (1 to 7), incremented by .H macro of corresponding level or by .HU macro if at level given by register Hu. Registers H2 to H7 are reset to 0 by any .H (or .HU) macro at a lower-numbered level.

Hb

Level of heading for which break occurs before output of body text. Default is 2.

Hc | Level of heading for which centering occurs. Default is 0.
Hi

Type of indent after heading. Values are 0 (left-justified), 1 (indented, the default), 2 (indented except after .H, .LC, .DE).

Hs | Level of heading for which space after heading occurs. Default is 2.
Ht | Numbering type of heading: 1 (single) or 0 (concatenated, the default).
Hu

Set level of heading at which unnumbered headings occur. Default is 2.

Hy | If set to 1, enable hyphenation. Default is 0.
L [dagger] | Set length of page. Default is 66v.
Le

Flag to print list of equations after table of contents: 0 (don't print, the default) or 1 (print).

Lf | Like Le, but for list of figures.
Li | Default indent of lists. Default is 5.
Ls

Set spacing between items in nested lists. Default is 6 (spacing between all levels of list).

Lt | Like Le, but for list of tables.
Lx | Like Le, but for list of exhibits.
N [dagger]

Set page numbering style:

0

All pages get header (the default)

1

Header printed as footer on page 1

2

No header on page 1

3

Section-page as footer

4

No header unless .PH has been invoked

5

Section-page and section-figure as footer

Np | Set numbering style for paragraphs: 0 (unnumbered) or 1 (numbered).
O

Offset of page. For nroff, value is unscaled number representing character positions; default is 9 (7.5i). For troff, value is scaled; default is .5i.

Oc

Set numbering style for pages in table of contents: 0 (lowercase roman, the default) or 1 (arabic).

Of

Set separator for figure number in captions. 0 (use period, the default); 1 (use hyphen).

P | Current page number.
Pi | Amount of indent for paragraph. Default is 5 for nroff and 3 for troff.
Ps | Amount of spacing between paragraphs. Default is 3v.
Pt

Paragraph type. Values are 0 (left-justified, the default), 1 (indented), 2 (indented except after .H, .LC, .DE).

Pv | Suppress ``PRIVATE" header.
Rf | Reference counter, incremented for each .RS.
S [dagger]

Default point size for troff. Default is 10. Vertical spacing is \nS+2.

Si | Standard indent for displays. Default is 5 for nroff and 3 for troff.
T [dagger]

Type of nroff output device. Sets registers for specific devices.

Tb | Table counter, incremented for each .TB.
U [dagger] | Style of nroff underlining for .H and .HU. If not set, use continuous underline; if set, don't underline punctuation and white space. Default is 0.
W [dagger] | Width of page (line and title length). Default is 6i.

Previous: 13.2 Predefined String Names | UNIX in a Nutshell: System V Edition | Next: 13.4 Other Reserved Macro and String Names
13.2 Predefined String Names | Book Index | 13.4 Other Reserved Macro and String Names


[Chapter 13] 13.4 Other Reserved Macro and String Names

Previous: 13.3 Number Registers Used in mm Chapter 13
mm Macros 		Next: 14. ms Macros

13.4 Other Reserved Macro and String Names

In mm, the only macro and string names you can safely use are names consisting of a single lowercase letter, or two character names whose first character is a lowercase letter and whose second character is anything but a lowercase letter. Of these, only c2 and nP are already used.

Previous: 13.3 Number Registers Used in mm | UNIX in a Nutshell: System V Edition | Next: 14. ms Macros
13.3 Number Registers Used in mm | Book Index | 14. ms Macros


[Chapter 14] ms Macros

Previous: 13.4 Other Reserved Macro and String Names Chapter 14 Next: 14.2 Number Registers for Page Layout

14. ms Macros

Contents:
Alphabetical Summary of ms Macros
Number Registers for Page Layout
Reserved Macro and String Names
Reserved Number Register Names

This section presents the following topics:

  • Alphabetical summary of ms macros

  • Number registers for page layout

  • Reserved macro and string names

  • Reserved number register names

14.1 Alphabetical Summary of ms Macros

  • .1C
  • .2C
  • .AB
  • .AE
  • .AI
  • .AU
  • .B
  • .B1
  • .B2
  • .BD
  • .BR
  • .BX
  • .CD
  • .DA
  • .DE
  • .DS
  • .EN
  • .EQ
  • .FS
  • .FE
  • .GO
  • .I
  • .ID
  • .IP
  • .KE
  • .KF
  • .KS
  • .LD
  • .LG
  • .LP
  • .MC
  • .ND
  • .NH
  • .NL
  • .PP
  • .QE
  • .QP
  • .QS
  • .R
  • .RE
  • .RP
  • .RS
  • .SB
  • .SG
  • .SH
  • .SM
  • .SU
  • .TE
  • .TH
  • .TL
  • .TS
  • .UL

Previous: 13.4 Other Reserved Macro and String Names | UNIX in a Nutshell: System V Edition | Next: 14.2 Number Registers for Page Layout
13.4 Other Reserved Macro and String Names | Book Index | 14.2 Number Registers for Page Layout


[Chapter 14] 14.2 Number Registers for Page Layout

Previous: 14.1 Alphabetical Summary of ms Macros Chapter 14
ms Macros 		Next: 14.3 Reserved Macro and String Names

14.2 Number Registers for Page Layout

Name | Meaning | Default
BI | Bibliographical indent | 3 ens
CW | Column width | 7/15 of line length
FL | Footnote length | 11/12 of line length
FM | Bottom margin | 1 inch
GW | Intercolumn gap | 1/15 of line length
HM | Top margin | 1 inch
LL | Line length | 6 inches
LT | Title length | 6 inches
PD | Paragraph spacing | .3v
PI | Paragraph indent | 5 ens
PO | Page offset | 26/27 inches
PS | Point size | 10 point
QI | Quotation indent | 5 ens
VS | Vertical line spacing | 12 point

Previous: 14.1 Alphabetical Summary of ms Macros | UNIX in a Nutshell: System V Edition | Next: 14.3 Reserved Macro and String Names
14.1 Alphabetical Summary of ms Macros | Book Index | 14.3 Reserved Macro and String Names


[Chapter 14] 14.3 Reserved Macro and String Names

Previous: 14.2 Number Registers for Page Layout Chapter 14
ms Macros 		Next: 14.4 Reserved Number Register Names

14.3 Reserved Macro and String Names

The following macro and string names are used by the ms package. Avoid using these names for compatibility with the existing macros. An italicized n means that the name contains a numeral (generally the interpolated value of a number register).

, | .] | : | [. | [c | [o | ^ | \` | ~
1C | 2C | AB | AE | AI | An | AT | AU | AX
B | B1 | B2 | BB | BG | BT | BX | C | C1
C2 | CA | CC | CF | CH | CM | CT | DA | DW
DY | EE | EG | EL | EM | EN | En | EQ | EZ
FA | FE | FF | FG | FJ | FK | FL | FN | FO
FS | FV | FX | FY | HO | I | IE | IH | IM
In | IP | IZ | KD | KF | KJ | KS | LB | LG
LP | LT | MC | ME | MF | MH | MN | MO | MR
ND | NH | NL | NP | OD | OK | PP | PT | PY
QE | QF | QP | QS | R | R3 | RA | RC | RE
Rn | RP | RS | RT | S0 | S2 | S3 | SG | SH
SM | SN | SY | TA | TC | TD | TE | TH | TL
TM | TQ | TR | TS | TT | TX | UL | US | UX
WB | WH | WT | XF | XK | XP |  |  |

Previous: 14.2 Number Registers for Page Layout | UNIX in a Nutshell: System V Edition | Next: 14.4 Reserved Number Register Names
14.2 Number Registers for Page Layout | Book Index | 14.4 Reserved Number Register Names


[Chapter 14] 14.4 Reserved Number Register Names

Previous: 14.3 Reserved Macro and String Names Chapter 14
ms Macros 		Next: 15. me Macros

14.4 Reserved Number Register Names

The following number register names are used by the ms package. An italicized n means that the name contains a numeral (generally the interpolated value of another number register).

nT | AJ | AV | BC | BD | BE | BH | BI | BQ
BW | CW | EF | FC | FL | FM | FP | GA | GW
H1 | H2 | H3 | H4 | H5 | HM | HT | I0 | IF
IK | IM | IP | IR | IS | IT | IX | In | Jn
KG | KI | KM | L1 | LE | LL | LT | MC | MF
MG | ML | MM | MN | NA | NC | ND | NQ | NS
NX | OJ | PD | PE | PF | PI | PN | PO | PQ
PS | PX | QI | QP | RO | SJ | ST | T. | TB
TC | TD | TK | TN | TQ | TV | TY | TZ | VS
WF | XX | YE | YY | ZN |  |  |  |

When you're writing your own macros, the safest bet is to use mixed case letters for macro names. (Using uppercase letters could conflict with reserved ms names, and using lowercase letters could conflict with troff requests.)

Previous: 14.3 Reserved Macro and String Names | UNIX in a Nutshell: System V Edition | Next: 15. me Macros
14.3 Reserved Macro and String Names | Book Index | 15. me Macros


[Chapter 15] me Macros

Previous: 14.4 Reserved Number Register Names Chapter 15 Next: 15.2 Predefined Strings

15. me Macros

Contents:
Alphabetical Summary of me Macros
Predefined Strings

This section presents the following topics:

  • Alphabetical summary of me macros

  • Predefined strings

15.1 Alphabetical Summary of me Macros

  • .1c
  • .2c
  • .ar
  • .b
  • .(b
  • .)b
  • .ba
  • .bc
  • .bi
  • .bl
  • .bu
  • .bx
  • .+c
  • .$c
  • .$C
  • .(c
  • .)c
  • .(d
  • .)d
  • .ef
  • .eh
  • .EN
  • .ep
  • .EQ
  • .$f
  • .(f
  • .)f
  • .fo
  • .$H
  • .$h
  • .he
  • .hl
  • .hx
  • .i
  • .ip
  • .ix
  • .(l
  • .)l
  • .ll
  • .lo
  • .lp
  • .m1
  • .m2
  • .m3
  • .m4
  • .n1
  • .n2
  • .np
  • .of
  • .oh
  • .$p
  • .$0
  • .$n
  • .pa
  • .pd
  • .pp
  • .q
  • .(q
  • .)q
  • .r
  • .rb
  • .re
  • .ro
  • .$s
  • .sh
  • .sk
  • .sx
  • .sz
  • .TE
  • .TH
  • .th
  • .tp
  • .TS
  • .u
  • .uh
  • .(x
  • .)x
  • .)x_
  • .x1
  • .xp
  • .(z
  • .)z
  • .++

Previous: 14.4 Reserved Number Register Names | UNIX in a Nutshell: System V Edition | Next: 15.2 Predefined Strings
14.4 Reserved Number Register Names | Book Index | 15.2 Predefined Strings


[Chapter 15] 15.2 Predefined Strings

Previous: 15.1 Alphabetical Summary of me Macros Chapter 15
me Macros 		Next: 16. Preprocessors

15.2 Predefined Strings

* | Footnote number, incremented by .)f macro
# | Delayed text number
[ | Superscript; move up and shrink type size
] | Undo superscript
< | Subscript; move down and shrink type size
> | Undo subscript
- | 3/4 em dash
dw | Day of week, as a word
mo | Month, as a word
td | Today's date
lq | Left quote mark
rq | Right quote mark

Previous: 15.1 Alphabetical Summary of me Macros | UNIX in a Nutshell: System V Edition | Next: 16. Preprocessors
15.1 Alphabetical Summary of me Macros | Book Index | 16. Preprocessors


[Chapter 16] Preprocessors

Previous: 15.2 Predefined Strings Chapter 16 Next: 16.2 Eqn

16. Preprocessors

Contents:
Tbl
Eqn
Pic

This section is divided into the following three subsections, each covering a different preprocessor of the nroff/troff formatting system:

  • The tbl preprocessor

  • The eqn preprocessor

  • The pic graphics language

Each of these preprocessors translates code into nroff/troff requests and escape sequences, which run independently of the formatter. Usually, one or more of these preprocessors are invoked as part of a command pipeline to format a file:

% pic file | tbl | eqn | troff | spooler

On multi-user systems, it is typical to have a general-purpose shell script for formatting. You would then select various command-line options to specify which (if any) preprocessors to include in your particular format command. But you can also invoke the preprocessors individually. This is useful for confirming that syntax is correct or for determining where it fails. For example, the command:

% tbl file

takes input between each .TS/.TE macro pair and converts it into tbl code. All other input is passed to output unchanged.

16.1 Tbl

Tbl is a preprocessor for formatting tables in nroff/troff. When used in a command pipeline, tbl should precede eqn. This makes output processing more efficient. Tbl has the following command-line syntax:

/usr/ucb/tbl [options] [files]

Options

-me

Prepend the me macros to the front of files.

-mm

Prepend the mm macros to the front of files.

-ms

Prepend the ms macros to the front of files.

-TX

Produce output using only full vertical line motions. This is useful when formatting with nroff or when printing to a device that does not support fractional line motion.

16.1.1 General Coding Scheme

In a text file, coding for tbl might look like this:

.TS H
options;
format1
format2.
Column Titles
.TH
Item1	Item2	Item3
Item1	Item2	Item3 ...
.TE

Successful processing of a table by tbl depends largely on the header lines, which consist of one line listing the options and one or more format lines. Each field of the table input must be separated by a tab or designated tab symbol, with each row typed entirely on a single line unless a field is enclosed by the text block symbols T{ and T}.

16.1.2 Tbl Macros

.TS | Start table.
.TE | End table.
.TS H | Used when the table will continue onto more than one page. Used with .TH to define a header that will print on every page.
.TH | With .TS H, ends the header portion of the table.
.T& | Continue table after changing format line.

16.1.3 Options

Options affect the entire table. Options can be separated by commas or spaces, but the line must end with a semicolon.

center | Center with current margins.
expand | Flush with current right and left margins.
blank | Flush with current left margin (the default).
box | Enclose table in a box.
doublebox | Enclose table in two boxes.
allbox | Enclose each table entry in a box.
tab (x) | Define the tab symbol to be x instead of a tab.
linesize n | Set type size of lines or rules (e.g., from box) to n points.
delim xy | Recognize x and y as the eqn delimiters.

16.1.4 Format

The format line affects the layout of individual columns and rows of the table. Each line contains a key letter for each column of the table. The column entries should be separated by spaces, and the format section must end with a period. Each line of format corresponds to one line of the table, except for the last, which corresponds to all following lines up to the next .T&, if any.

16.1.4.1 Key Letters

c | Center.
l | Flush left.
r | Flush right.
n | Align numerical entries.
a | Align alphabetic subcolumns.
s | Horizontally span previous column entry across this column.
^ | Vertically span (center) entry from previous row down through this row.

16.1.4.2 Key Modifiers

These must follow a key letter.

b | Boldface.
i | Italics.
fx | Font x.
pn | Point size.
vn | Vertical line spacing, in points. Applies only to text blocks.
t | Begin any corresponding vertically-spanned table entry (i.e., from ^) at the top line of its range.
e | Equal width columns.
w(n) | Minimum column width. Also used with text blocks. n can be given in any acceptable troff units.
n | Amount of separation (in ens) between columns (default is 3).
| | Separate columns with a single vertical line. Typed between key letters.
|| | Separate columns with a double vertical line. Typed between key letters.
_ | Separate rows with a single horizontal line. Used in place of a key letter.
= | Separate rows with a double horizontal line. Used in place of a key letter.

16.1.5 Data

The data portion includes both the heading and text of the table. Each table entry must be separated by a tab symbol.

.xx | Troff requests may be used (such as .sp n, .na, etc.).
\ | As last character in a line, combine following line with current line (hide newline).
\^ | Span table entry that is above this row, bringing it down to be vertically centered.
\&_ or = | As the only character in a line, extend a single or double horizontal line the full width of the table.
\$_ or \$= | Extend a single or double horizontal line the full width of the column.
\_ | Extend a single horizontal line the width of the column's contents.
\Rx | Print x's as wide as the column's contents.
...[tab]T{ | Start text block as a table entry. Must end a line. Necessary when a line of text is input over more than one line, or will span more than one line of output.
...T}[tab] | End text block. Must begin a line.

16.1.6 A Tbl Example

Input:

.TS
center box linesize(6) tab(@);
cb s s.
Horizontal Local Motions
_
.T&
ci | ci s
ci | ci s
ci | ci | ci
c | l s.
Function@Effect in
\^@_
\^@troff@nroff
_
\eh'n'@Move distance N
\e(space)@Unpaddable space-size space
\e0@Digit-size space
_
.T&
c | l | l.
\e|@1/6 em space@ignored
\e^@1/12 em space@ignored
.TE

Result:

Horizontal Local Motions
Function | Effect in
 | troff | nroff
\h'n' | Move distance N
\(space) | Unpaddable space-size space
\0 | Digit-size space
\| | 1/6 em space | ignored
\^ | 1/12 em space | ignored

Previous: 15.2 Predefined Strings | UNIX in a Nutshell: System V Edition | Next: 16.2 Eqn
15.2 Predefined Strings | Book Index | 16.2 Eqn


[Chapter 16] 16.2 Eqn

Previous: 16.1 Tbl Chapter 16
Preprocessors 		Next: 16.3 Pic

16.2 Eqn

Eqn is a preprocessor designed to facilitate the typesetting of mathematical equations. Use neqn with nroff. Eqn has the following command-line syntax:

/usr/ucb/eqn [options] [files]

Options
-dxy

Use x and y as start and stop delimiters; same as specifying the eqn directive delimxy.

-fn

Change to font n; same as the gfont directive.

-pn

Reduce size of superscripts and subscripts by n points. If -p is not specified, the default reduction is 3 points.

-sn

Reduce the point size by n points; same as the gsize directive.

-Tdev

Format output to device dev. The default value comes from the TYPESETTER environment variable. Not available with neqn.

16.2.1 Eqn Macros

.EQ

Start typesetting mathematics.

.EN

End typesetting mathematics.

Use the checkeq command to check for unmatched macro pairs.

16.2.2 Mathematical Characters

The character sequences below are recognized and translated as shown:

Character | Translation | Character | Translation
>= |  | approx | ~
<= |  | nothing |
== |  | cdot | .
!= |  | times | ×
+- | ± | del | [nabla]
-> | -> | grad | [nabla]
<- | <- | ... | ...
<< | << | ,..., | ,...,
>> | >> | sum | [sum]
inf | [infinity] | int | [integral]
partial | d | prod | [product]
half | ½ | union | U
prime | ' | inter | [cap]

16.2.3 Mathematical Text

Digits, parentheses, brackets, punctuation marks, and the following mathematical words are printed out in Roman font:

sin     cos     tan     arc
sinh    cosh    tanh
and     if      for     det
max     min     lim
log     ln      exp
Re      Im

16.2.4 Greek Characters

Greek letters can be printed in uppercase or lowercase. To obtain Greek letters, simply spell them out. Some uppercase Greek letters are not supported because they can be specified by an Arabic equivalent (e.g, A for alpha, B for beta).

Character | Translation | Character | Translation
alpha | [alpha] | tau | [tau]
beta | [beta] | upsilon | [upsilon]
gamma | [gamma] | phi | [phi]
delta | [delta] | chi | [chi]
epsilon | [epsilon] | psi | [psi]
zeta | [zeta] | omega | [omega]
eta | [eta] | GAMMA | [Gamma]
theta | [theta] | DELTA | [Delta]
iota | [iota] | THETA | [Theta]
kappa | [kappa] | LAMBDA | [Lambda]
lambda | [lambda] | XI | [Xi]
mu | [mu] | PI | [Pi]
nu | [nu] | SIGMA | [Sigma]
xi | [xi] | UPSILON | [Upsilon]
omicron | [omicron] | PHI | [Phi]
pi | [pi] | PSI | [Psi]
rho | [rho] | OMEGA | [Omega]
sigma | [sigma] |  |

16.2.5 Diacritical Marks

Several keywords are available to mark the tops of characters. Eqn centers a mark at the correct height. bar and under will span the necessary length.

Character | Translation
x dot | x·
x dotdot | x¨
x hat |
x tilde |
x vec | x->
x dyad | x<->
x bar | x¯
x under |

16.2.6 Keywords Recognized by Eqn

In addition to character names and diacritical marks, eqn recognizes the following keywords:

above

Separate the pieces of a pile or matrix column.

back n

Move backwards horizontally n 1/100's of an m.

bold

Change to bold font.

ccol

Center align a column of a matrix.

cpile

Make a centered pile (same as pile).

define

Create a name for a frequently used string.

delim xy

Define two characters to mark the left and right ends of an eqn equation to be printed in line. Use delim off to turn of delimiters.

down n

Move down n 1/100's of an m.

fat

Widen the current font by overstriking it.

font x

Change to font x, where x is the one-character name or the number of a font.

from

Used in summations, integrals, and similar constructions to signify the lower limit.

fwd n

Move forward horizontally n 1/100's of an em.

gfont x

Set a global font x for all equations.

gsize n

Set a global size for all equations.

italic

Change to italic font.

lcol

Left justify a column of a matrix.

left

Create big brackets, big braces, big bars, etc.

lineup

Line up marks in equations on different lines.

lpile

Left justify the elements of a pile.

mark

Remember the horizontal position in an equation. Used with lineup.

matrix

Create a matrix.

ndefine

Create a definition which takes effect only when neqn is running.

over

Make a fraction.

pile

Make a vertical pile with elements centered above one another.

rcol

Right adjust a column of a matrix.

right

Create big brackets, big braces, big bars, etc.

roman

Change to roman font.

rpile

Right justify the elements of a pile.

size n

Change the size of the font to n.

sqrt

Draw a square root sign.

sub

Start a subscript.

sup

Start a superscript.

tdefine

Make a definition which will apply only for eqn.

to

Used in summations, integrals, and similar constructions to signify the upper limit.

up n

Move up n 1/100's of an em.

~

Force extra space into the output.

^

Force a space one half the size of the space forced by ~ .

{ }

Force eqn to treat an element as a unit.

'...'

A string within quotes is not subject to alterations by eqn.

16.2.7 Precedence

If you don't use braces, eqn will do operations in the order shown in this list, reading from left to right.

dyad | vec | under | bar
tilde | hat | dot | dotdot
fwd | back | down | up
fat | roman | italic | bold
size | sub | sup | sqrt
over | from | to |

These operations group to the left:

over   sqrt   left   right

All others group to the right.

16.2.8 Eqn Examples

Input:

.EQ
delim %%
.EN
%sum from i=0 to inf c sup i~=~lim from {m -> inf}
sum from i=0 to m c sup i%
.EQ
delim off
.EN

Result: Figure 16.0

Input:

.EQ
delim %%
.EN
%x ~=~ left [ { -b ~+-~ sqrt {b sup 2 - ~4ac} }
over 2a right ]%
.EQ
delim off
.EN

Result: Figure 16.0

Previous: 16.1 Tbl | UNIX in a Nutshell: System V Edition | Next: 16.3 Pic
16.1 Tbl | Book Index | 16.3 Pic


[Chapter 16] 16.3 Pic

Previous: 16.2 Eqn Chapter 16
Preprocessors 		Next: 17. The SCCS Utility

16.3 Pic

Pic is a graphics language program that facilitates the drawing of simple flowcharts and diagrams. Pic offers dozens of ways to draw a picture, not only because of the many abbreviations it allows, but because pic tries to combine the language of geometry with English. For example, you can specify a line by its direction, magnitude, and starting point, yet you can often achieve the same effect by simply stating, "from there to there."

Pic has the following command-line syntax:

/usr/ucb/pic [files]

Full descriptions of primitive objects in pic can be ended by starting another line, or by the semicolon character (;). A single primitive description can be continued on the next line, however, by ending the first with a backslash character (\). Comments may be placed on lines beginning with the pound sign (#).

16.3.1 Pic Macros

.PS [h [w]] | Start pic description. h and w, if specified, are the desired height and width of the picture; the full picture will be made to expand or contract to fill this space.
.PS < file | Read contents of file in place of current line.
.PE | End pic description.
.PF | End pic description and return to vertical position before matching PS.
.xx | Troff request (or macro) xx.

16.3.2 Declarations

At the beginning of a pic description, you may declare a new scale, and declare any number of variables. Pic assumes you want a 1-to-1 scale, where units are inches by default. You can declare a different scale, say 1 = one-nth of an inch, by declaring:

scale = n

Pic takes variable substitutions for numbers used in the description. Instead of:

line right n

you may use a lowercase character as a variable, for example a, by declaring at the top of the description:

a = n

You may then write:

line right a

16.3.3 Primitives

Pic recognizes several basic graphical objects, or primitives. These primitives are specified by the following keywords:

arc      circle    move
arrow    ellipse   spline
box      line      "text"

16.3.3.1 Syntax

Primitives may be followed by relevant options. Options are discussed later in this section.

arc [cw] [options] ["text"]

A fraction of a circle (default is 1/4 of a circle). The cw option specifies a clockwise arc; default is counter-clockwise.

arrow [options] ["text"]

Draw an arrow. Essentially the same as line ->.

box [options] ["text"]

Draw a box.

circle [options] ["text"]

Draw a circle.

ellipse [options] ["text"]

Draw an ellipse.

line [options] ["text"]

Draw a line.

move [options] ["text"]

A move of position in the drawing. Essentially, an invisible line.

spline [options] ["text"]

A line, with the feature that a then option results in a gradual (sloped) change in direction.

"text"

Text centered at current point.

16.3.4 Options

The options below are grouped by function. Note that at, with, and from specify points. Points may be expressed as Cartesian coordinates or with respect to previous objects.

right [n]

left [n]

up [n]

down [n]

The direction of the primitive; default is the direction in which the previous description had been heading. Create diagonal motion by using two directions on the option line. Each direction can be followed by a specified length n.

rad n

diam n

Create the primitive using radius or diameter n.

ht n

wid n

Create the primitive using height or width n. For an arrow, line, or spline, height and width refer to arrowhead size.

same

Create the primitive using the same dimensions specified for the most recent matching primitive.

at point

Center the primitive at point.

with .position at point

Designate the position of the primitive to be at point.

from point1 to point2

Draw the primitive from point1 to point2.

->

Direct the arrowhead forward.

<-

Direct the arrowhead backward.

<->

Direct the arrowhead both ways.

chop n m

Chop off n from beginning of primitive, and m from end. With only one argument, the same value will be chopped from both ends.

dotted

dashed

invis

Draw the primitive using lines that are dotted, dashed, or invisible. (An invisible object still occupies space in the output.) Default is solid line.

then ...

Continue primitive in a new direction. Relevant only to lines, splines, moves, and arrows. Can be placed before or after any text.

16.3.5 Text

Text must be placed within quotes. To break the line, break into two (or more) sets of quotes. Text always appears centered within the object, unless given one of the following arguments:

ljust

Text appears flush left, vertically centered.

rjust

Text appears flush right, vertically centered.

above

Text appears above the center.

below

Text appears below the center.

16.3.6 Object Blocks

Several primitives can be combined to make a complex object (for example, an octagon). This complex object can be treated as a single object by declaring it as a block:

Object: [
     description
      .
      .
      .
]

Brackets are used as delimiters. Note that the object is declared as a proper noun, hence should begin with a capital letter.

16.3.7 Macros

The same sequence of commands can be repeated by using macros. The syntax is:

define sequence %
      description
          .
          .
          .
      %

Here we used the percent sign (%) as the delimiter, but you can use any character that isn't in the description.

Macros can take variables, expressed in the definition as $1 through $9. Invoke the macro with the syntax:

sequence(value1,value2,...)

16.3.8 Positioning

In a pic description, the first action begins at (0,0) unless otherwise specified with coordinates. Thus, as objects are placed above and left of the first object, the point (0,0) moves down and right on the drawing.

All points are ultimately translated by the formatter into x- and y-coordinates. You may therefore refer to a specific point in the picture by incrementing or decrementing the coordinates. For example:

2nd ellipse - (3,1)

You may refer to the x- and y-coordinates of an object by placing .x or .y at the end. For example:

last box.x

refers to the x-coordinate of the most recent box drawn. You can refer to some of the object's physical attributes in a similar way:

.x

x-coordinate of object's center.

.y

y-coordinate of object's center.

.ht

Height of object.

.wid

Width of object.

.rad

Radius of object.

Unless otherwise positioned, each object begins at the point where the last object left off. However, if a command (or sequence of commands) is set off by curly braces ({ }), pic then returns to the position before the first brace.

16.3.8.1 Positioning Between Objects

To refer to a previous object, use proper names. This can be done two ways:

  1. By referring to it by order. For example:

    1st box
3rd box
last box
2nd last box

  2. By declaring it with a name, in initial caps, on its declaration line. For example:

    Line1: line 1.5 right from last box.sw

To refer to a point between two objects, or between two points on the same object, you may write:

fraction of the way between first.position and second.position

or (abbreviated):

fraction<first.position,second.position>

16.3.8.2 Corners

When you refer to a previous object, pic assumes you mean the object's center unless you specify a corner. To specify a corner, use either of these forms:

.corner of object
object.corner

For example:

.sw of last box
last box.sw

Valid corners can be specified as any of the following:

n | North
s | South
e | East
w | West
ne | Northeast
nw | Northwest
se | Southeast
sw | Southwest
t | Top (same as n)
b | Bottom (same as s)
r | Right (same as e)
l | Left (same as w)
start | Point where drawing of object began
end | Point where drawing of object ended

You may also refer to the following parts of an object:

upper right        lower right
upper left         lower left

16.3.9 Arithmetic Operators

Pic recognizes the operators below:

+ | Addition.
- | Subtraction.
* | Multiplication.
/ | Division
% | Modulus (remainder after division).

16.3.10 Default Values

The default dimensions of objects are controlled by various system variables. You can change these defaults by typing a description line of the form:

variable = value

Variable | Default | Variable | Default
arcrad | 0.25 | ellipsewid | 0.75
arrowwid | 0.05 | linewid | 0.5
arrowht | 0.1 | lineht | 0.5
boxwid | 0.75 | movewid | 0.5
boxht | 0.5 | moveht | 0.5
circlerad | 0.25 | scale | 1
dashwid | 0.05 | textht | 0
ellipseht | 0.5 | textwid | 0

16.3.11 A Pic Example

Input:

.PS
define smile %
a = $1
circle radius a at 0,0
arc cw radius a*.75 from a*.5,-a*.25 to -a*.5,-a*.25
"\(bu" at a*.33,a*.25
"\(bu" at a*-.33,a*.25
%
smile(.5)
.PE

Result: Figure 16.0

Previous: 16.2 Eqn | UNIX in a Nutshell: System V Edition | Next: 17. The SCCS Utility
16.2 Eqn | Book Index | 17. The SCCS Utility


[Chapter 17] The SCCS Utility

Previous: 16.3 Pic Chapter 17 Next: 17.2 Basic Operation

17. The SCCS Utility

Contents:
Overview of Commands
Basic Operation
Identification Keywords
Data Keywords
Alphabetical Summary of SCCS Commands
sccs and Pseudo-commands

This section presents the following topics:

  • Overview of commands

  • Basic operation

  • Identification keywords

  • Data keywords

  • Alphabetical summary of commands

  • sccs and pseudo-commands

Note: SCCS users who are more familiar with RCS may benefit from the "Conversion Guide for SCCS Users" in Section 18. This lists SCCS commands and their RCS equivalents.

The Source Code Control System (SCCS) lets you keep track of each revision of a document, avoiding the confusion that often arises from having several versions of one file on line. SCCS is particularly useful when programs are enhanced but the original version is still needed.

All changes to a file are stored in a file named s.file, which is called an SCCS file. Each time a file is "entered" into SCCS, SCCS notes which lines have been changed or deleted since the most recent version. From that information, SCCS can regenerate the file on demand. Each set of changes depends on all previous sets of changes.

Each set of changes is called a delta and is assigned an SCCS identification string (sid). The sid consists of either two components, release and level numbers (in the form a.b), or of four components: the release, level, branch, and sequence numbers (in the form a.b.c.d). The branches and sequences are for situations when two on-running versions of the same file are recorded in SCCS. For example, delta 3.2.1.1 refers to release 3, level 2, branch 1, sequence 1.

17.1 Overview of Commands

SCCS commands fall into several categories:

17.1.1 Basic Set Up and Editing

admin

Create new SCCS files and change their parameters.

get

Retrieve versions of SCCS files.

delta

Create a new version of an SCCS file (i.e., append a new delta).

unget

Cancel a get operation; don't create a new delta.

17.1.2 Fixing Deltas

cdc

Change the comment associated with a delta.

comb

Combine consecutive deltas into a single delta.

rmdel

Remove an accidental delta from an SCCS file.

17.1.3 Information

help

Print a command synopsis or clarify diagnostic messages.

prs

Print portions of SCCS files in a specified format.

sact

Show editing activity on SCCS files.

what

Search for all occurrences of the pattern get substitutes for %Z%, and print out the following text.

17.1.4 Comparing Files

sccsdiff

Show the differences between any two SCCS files.

val

Validate an SCCS file.

Previous: 16.3 Pic | UNIX in a Nutshell: System V Edition | Next: 17.2 Basic Operation
16.3 Pic | Book Index | 17.2 Basic Operation


[Chapter 17] 17.2 Basic Operation

Previous: 17.1 Overview of Commands Chapter 17
The SCCS Utility 		Next: 17.3 Identification Keywords

17.2 Basic Operation

This subsection outlines the steps to follow when using SCCS:

  • Creating an SCCS file

  • Retrieving a file

  • Creating new releases and branches

  • Recording changes

17.2.1 Creating an SCCS File

The admin command with the -i option creates and initializes SCCS files. For example:

admin -ich01 s.ch01

creates a new SCCS file and initializes it with the contents of ch01, which will become delta 1.1. The message, "No id keywords (cm7)" appears if you do not specify any keywords. In general, "id keywords" refer to variables in the files that are replaced with appropriate values by get, identifying the date and time of creation, the version retrieved, etc. A listing of identification keywords occurs later in this section.

Once the s.ch01 file is created, the original file ch01 can be removed, since it can be easily regenerated with the get command.

17.2.2 Retrieving a File

The get command can retrieve any version of a file from SCCS. Using the example above, you can retrieve ch01 by entering:

get -e s.ch01

and the messages:

1.1
new delta 1.2
272 lines

may appear. This indicates that you are "getting" delta 1.1, and the resulting file has 272 lines of text. When the file is reentered into the SCCS file s.ch01 with the delta command, its changes are delta 1.2.

The -e option indicates to SCCS that you intend to make more changes to the file and then reenter it into SCCS. Without this option, you will receive the file with read-only permissions. The -e option, besides releasing the file with read-write permissions, also creates a file p.ch01, which records information that will be used by SCCS when the file is returned.

17.2.3 Creating New Releases and Branches

The -r option to get tells SCCS what release and level number you want, but if no level is specified it defaults to the highest level available. With the command:

get -r3.2 ch01

delta 3.2 will be the release. However, the command:

get -r3 ch01

returns the highest-numbered level in release 3, for example 3.8. With the -r option omitted, get defaults to the highest release, highest level - in other words, the latest version.

When major changes are in store for a file, you may want to begin a new release of the file. You can do that by "getting" the file with the next highest release number. For example, if the latest release of a file is 3.2, and you want to start release 4, enter:

get -e -r4 ch01

You will receive the message:

3.2
new delta 4.1
53 lines

If you want to make a change to an older version of the same file, you can enter:

get -e -r2.2 ch01

and receive the message:

2.2
new delta 2.2.1.1
121 lines

You have now created a new branch from the trunk, stemming from version 2.2. Changes in this delta will not affect those in the trunk deltas, i.e., 2.3, 3.1, etc.

17.2.4 Recording Changes

Once changes have been made to the SCCS file, return it to SCCS with the command:

delta s.ch01

You are prompted for comments on the changes. The delta command then does its own get and uses diff to compare the new version of the file with the most recent version. It then prints messages giving the new release number and the number of lines that were inserted, deleted, and unchanged.

Previous: 17.1 Overview of Commands | UNIX in a Nutshell: System V Edition | Next: 17.3 Identification Keywords
17.1 Overview of Commands | Book Index | 17.3 Identification Keywords


[Chapter 17] 17.3 Identification Keywords

Previous: 17.2 Basic Operation Chapter 17
The SCCS Utility 		Next: 17.4 Data Keywords

17.3 Identification Keywords

The keywords below may be used in an SCCS file. A get command will expand these keywords to the value described.

%A% | Shorthand for providing what strings for program files; %A% = %Z%%Y% %M% %I%%Z%
%B% | Branch number.
%C% | Current line number, intended for identifying where error occurred.
%D% | Current date (YY/MM/DD).
%E% | Date newest applied delta was created (YY/MM/DD).
%F% | SCCS file name.
%G% | Date newest applied delta was created (MM/DD/YY).
%H% | Current date (MM/DD/YY).
%I% | sid of the retrieved text (%R%.%L%.%B%.%S%).
%L% | Level number.
%M% | Module name (filename without .s prefix).
%P% | Fully qualified SCCS file name.
%Q% | Value of string, as defined by admin -fq string.
%R% | Release number.
%S% | Sequence number.
%T% | Current time (HH:MM:SS).
%U% | Time newest applied delta was created (HH:MM:SS).
%W% | Another shorthand like %A%; %W% = %Z%%M% tab %I%
%Y% | Module type, as defined by admin -ft type.
%Z% | String recognized by what; that is, @(#).

Previous: 17.2 Basic Operation | UNIX in a Nutshell: System V Edition | Next: 17.4 Data Keywords
17.2 Basic Operation | Book Index | 17.4 Data Keywords


[Chapter 17] 17.4 Data Keywords

Previous: 17.3 Identification Keywords Chapter 17
The SCCS Utility 		Next: 17.5 Alphabetical Summary of SCCS Commands

17.4 Data Keywords

Data keywords specify which parts of an SCCS file are to be retrieved and output using the -d option of the prs command.

:A: | Form of what string.
:B: | Branch number.
:BD: | Body.
:BF: | Branch flag.
:C: | Comments for delta.
:CB: | Ceiling boundary.
:D: | Date delta created (:Dy:/:Dm:/:Dd:).
:Dd: | Day delta created.
:Dg: | Deltas ignored (sequence number).
:DI: | Sequence number of deltas (:Dn:/:Dx:/:Dg:).
:DL: | Delta line statistics (:Li:/:Ld:/:Lu:).
:Dm: | Month delta created.
:Dn: | Deltas included (sequence number).
:DP: | Predecessor delta sequence number.
:Ds: | Default sid.
:DS: | Delta sequence number.
:Dt: | Delta information.
:DT: | Delta type.
:Dx: | Deltas excluded (sequence number).
:Dy: | Year delta created.
:F: | SCCS file name.
:FB: | Floor boundary.
:FD: | File descriptive text.
:FL: | Flag list.
:GB: | Gotten body.
:I: | SCCS ID string (sid) (:R:.:L:.:B:.:S:).
:J: | Joint edit flag.
:KF: | Keyword error/warning flag.
:KV: | Keyword validation string.
:L: | Level number.
:Ld: | Lines deleted by delta.
:Li: | Lines inserted by delta.
:LK: | Locked releases.
:Lu: | Lines unchanged by delta.
:M: | Module name.
:MF: | Modification validation flag.
:MP: | Modification validation program name.
:MR: | Modification numbers for delta.
:ND: | Null delta flag.
:P: | Username of programmer who created delta.
:PN: | SCCS file pathname.
:Q: | User-defined keyword.
:R: | Release number.
:S: | Sequence number.
:T: | Time delta created (:Th:::Tm:::Ts:.).
:Th: | Hour delta created.
:Tm: | Minutes delta created.
:Ts: | Seconds delta created.
:UN: | User names.
:W: | Form of what string.
:Y: | Module type flag.
:Z: | what string delimiter.

Previous: 17.3 Identification Keywords | UNIX in a Nutshell: System V Edition | Next: 17.5 Alphabetical Summary of SCCS Commands
17.3 Identification Keywords | Book Index | 17.5 Alphabetical Summary of SCCS Commands


[Chapter 17] 17.5 Alphabetical Summary of SCCS Commands

Previous: 17.4 Data Keywords Chapter 17
The SCCS Utility 		Next: 17.6 sccs and Pseudo-commands

17.5 Alphabetical Summary of SCCS Commands

File arguments to SCCS commands can be either filenames or directory names. Naming a directory will cause all the files in that directory to be processed, with nonapplicable and nonreadable files ignored. If in place of a file argument a dash (-) is entered, the command will read from standard input for the names of files to be processed, one on each line.

  • admin
  • cdc
  • comb
  • delta
  • get
  • help
  • prs
  • rmdel
  • sact
  • sccsdiff
  • unget
  • val
  • what

Previous: 17.4 Data Keywords | UNIX in a Nutshell: System V Edition | Next: 17.6 sccs and Pseudo-commands
17.4 Data Keywords | Book Index | 17.6 sccs and Pseudo-commands


[Chapter 17] 17.6 sccs and Pseudo-commands

Previous: 17.5 Alphabetical Summary of SCCS Commands Chapter 17
The SCCS Utility 		Next: 18. The RCS Utility

17.6 sccs and Pseudo-commands

The compatibility packages include sccs, a front end to the SCCS utility. This command provides a user-friendly interface to SCCS and has the following command-line syntax:

/usr/ucb/sccs [options] command [SCCS_flags] [files]

In addition to providing all of the regular SCCS commands, sccs offers pseudo- commands. These are easy-to-use, prebuilt combinations of the regular SCCS commands. options apply only to the sccs interface. command is the SCCS command or pseudo-command to run, and SCCS_flags are specific options passed to the SCCS command being run.

sccs makes it easier to specify files because it automatically prepends SCCS/s. to any filename arguments. For example:

sccs get -e file.c

would be interpreted as:

get -e SCCS/s.file.c

17.6.1 Options

-dprepath

Locate files in prepath rather than in current directory. For example:

sccs -d/home get file.c

is interpreted as:

get /home/SCCS/s.file.c

-pendpath

Access files from directory endpath instead of SCCS. For example:

sccs -pVERSIONS get file.c

is interpreted as:

get VERSIONS/s.file.c

-r

Invoke sccs as the real user instead of as the effective user.

17.6.2 Pseudo-commands

Equivalent SCCS actions are indicated in parentheses.

check

Like info, but return nonzero exit codes instead of filenames.

clean

Remove from current directory any files that aren't being edited under SCCS (via get -e, for example).

create

Create SCCS files (admin -i followed by get).

deledit

Same as delta followed by get -e.

delget

Same as delta followed by get.

diffs

Compare file's current version and SCCS version (like sccsdiff).

edit

Get a file to edit (get -e).

enter

Like create but without the subsequent get (admin -i).

fix

Same as rmdel (must be followed by -r).

info

List files being edited (similar to sact).

print

Print information (like prs -e followed by get -p -m)

tell

Like info, but list one filename per line.

unedit

Same as unget.

Previous: 17.5 Alphabetical Summary of SCCS Commands | UNIX in a Nutshell: System V Edition | Next: 18. The RCS Utility
17.5 Alphabetical Summary of SCCS Commands | Book Index | 18. The RCS Utility


[Chapter 18] The RCS Utility

Previous: 17.6 sccs and Pseudo-commands Chapter 18 Next: 18.2 Basic Operation

18. The RCS Utility

Contents:
Overview of Commands
Basic Operation
General RCS Specifications
Conversion Guide for SCCS Users
Alphabetical Summary of Commands

This section presents the following topics:

  • Overview of commands

  • Basic operation

  • General RCS specifications

  • Conversion guide for SCCS users

  • Alphabetical summary of commands

As with SCCS in the preceding section, the Revision Control System (RCS) is designed to keep track of multiple file revisions, thereby reducing the amount of storage space needed. With RCS you can automatically store and retrieve revisions, merge or compare revisions, keep a complete history (or log) of changes, and identify revisions using symbolic keywords. RCS is believed to be more efficient than SCCS. RCS is not part of standard SVR4 but can be obtained from the Free Software Foundation in Cambridge, Mass. This section describes Version 5.6, although we note important differences in versions 4 and 5.

18.1 Overview of Commands

The three most important RCS commands are:

ci

Check in revisions (put a file under RCS control).

co

Check out revisions.

rcs

Set up or change attributes of RCS files.

Two commands provide information about RCS files:

ident

Extract keyword values from an RCS file.

rlog

Display a summary (log) about the revisions in an RCS file.

You can compare RCS files with these commands:

merge

Incorporate changes from two files into a third file.

rcsdiff

Report differences between revisions.

rcsmerge

Incorporate changes from two RCS files into a third RCS file.

The following commands help with configuration management. However, they are considered optional, so they are not always installed.

rcsclean

Remove working files that have not been changed.

rcsfreeze

Label the files that make up a configuration.

Previous: 17.6 sccs and Pseudo-commands | UNIX in a Nutshell: System V Edition | Next: 18.2 Basic Operation
17.6 sccs and Pseudo-commands | Book Index | 18.2 Basic Operation


[Chapter 18] 18.2 Basic Operation

Previous: 18.1 Overview of Commands Chapter 18
The RCS Utility 		Next: 18.3 General RCS Specifications

18.2 Basic Operation

Normally, you maintain RCS files in a subdirectory called RCS, so the first step in using RCS should be:

mkdir RCS

Next, you place an existing file (or files) under RCS control by running the check-in command:

ci file

This creates a file called file,v in directory RCS. file,v is called an RCS file, and it will store all future revisions of file. When you run ci on a file for the first time, you are prompted to describe the contents. ci then deposits file into the RCS file as revision 1.1.

To edit a new revision, check out a copy:

co -l file

This causes RCS to extract a copy of file from the RCS file. You must lock the file with -l to make it writable by you. This copy is called a working file. When you're done editing, you can record the changes by checking the working file back in again:

ci file

This time, you are prompted to enter a log of the changes made, and the file is deposited as revision 1.2. Note that a check in normally removes the working file. To retrieve a read-only copy, do a check out without a lock:

co file

This is useful when you need to keep a copy on hand for compiling or searching. As a shortcut to the previous ci/co, you could type:

ci -u file

This checks in the file but immediately checks out a read-only copy. To compare changes between a working file and its latest revision, you can type:

rcsdiff file

Another useful command is rlog, which shows a summary of log messages. System administrators can use the rcs command to set up default behavior of RCS.

Previous: 18.1 Overview of Commands | UNIX in a Nutshell: System V Edition | Next: 18.3 General RCS Specifications
18.1 Overview of Commands | Book Index | 18.3 General RCS Specifications


[Chapter 18] 18.3 General RCS Specifications

Previous: 18.2 Basic Operation Chapter 18
The RCS Utility 		Next: 18.4 Conversion Guide for SCCS Users

18.3 General RCS Specifications

This subsection discusses:

  • Keyword substitution

  • Revision numbering

  • Specifying the date

  • Specifying states

  • Standard options and environment variables

18.3.1 Keyword Substitution

RCS lets you place keyword variables in your working files. These variables are later expanded into revision notes. You can then use the notes either as embedded comments in the input file, or as text strings that appear when the output is printed. To create revision notes via keyword substitution, follow this procedure:

  1. In your working file, type any of the keywords listed below.

  2. Check the file in.

  3. Check the file out again. Upon checkout, the co command expands each keyword to include its value. That is, co replaces instances of:

    $keyword$

    with:

    $keyword:value$.

  4. Subsequent check in and check out of a file will update any existing keyword values. Unless otherwise noted below, existing values are replaced by new values.

Note: In RCS Version 5, many commands have a -k option that provides more flexibility during keyword substitution.

18.3.2 Keywords

$Author$

Username of person who checked in revision.

$Date$

Date and time of check in.

$Header$

A title that includes RCS file's full pathname, revision number, date, author, state, and (if locked) the person who locked the file.

$Id$

Same as $Header$, but exclude the full pathname of the RCS file.

$Locker$

Username of person who locked the revision. If the file isn't locked, this value is empty.

$Log$

The message that was typed during check in to describe the file, preceded by the RCS filename, revision number, author, and date. Log messages accumulate rather than being overwritten.

$RCSfile$

The RCS filename, without its pathname.

$Revision$

The assigned revision number.

$Source$

The RCS filename, including its pathname.

$State$

The state assigned by the -s option of ci or rcs.

18.3.3 Example Values

Let's assume that the file /projects/new/chapter3 has been checked in and out by a user named daniel. Here's what keyword substitution would produce for each keyword, for the second revision of the file:

$Author: daniel $
$Date: 92/03/18 17:51:36 $
$Header: /projects/new/chapter3,v 1.2 92/03/18 17:51:36 daniel \
    Exp Locker: daniel $
$Id: chapter3,v 1.2 92/03/18 17:51:36 daniel Exp Locker: daniel $
$Locker: daniel $
$Log:    chapter3,v $
# Revision 1.2  92/03/18  17:51:36  daniel
# Added section on error-handling
#
# Revision 1.1  92/03/18  16:49:59  daniel
# Initial revision
#

$RCSfile: chapter3,v $

$Revision: 1.2 $

$Source: /projects/new/chapter3,v $

$State: Exp $

18.3.4 Revision Numbering

Unless told otherwise, RCS commands typically operate on the latest revision. Some commands have a -r option that is used to specify a revision number. In addition, many options accept a revision number as an optional argument. (In the command summary, this argument is shown as [R].) Revision numbers consist of up to four fields: release, level, branch, and sequence, but most revisions consist of only the release and level. For example, you can check out revision 1.4 as follows:

co -l -r1.4 ch01

When you check it in again, the new revision will be marked as 1.5. But suppose the edited copy needs to be checked in as the next release. You would type:

ci -r2 ch01

This creates revision 2.1. You can also create a branch from an earlier revision. The following command creates revision 1.4.1.1:

ci -r1.4.1 ch01

Numbers are not the only way to specify revisions, though. You can assign a text label as a revision name, using the -n option of ci or rcs. You can also specify this name in any option that accepts a revision number for an argument. For example, you could check in each of your C programs, using the same label regardless of the current revision number:

ci -u -nPrototype *.c

In addition, RCS version 5.6 lets you specify a $, which means the revision number extracted from the keywords of a working file. For example:

rcsdiff -r$ ch01

compares ch01 to the revision that is checked in. You can also combine names and symbols. The command:

rcs -nDraft:$ ch*

assigns a name to the revision numbers associated with several chapter files.

18.3.5 Specifying the Date

Revisions are timestamped by time and date of check in. Several keyword strings include the date in their values. Dates can be supplied in options to ci, co, and rlog. RCS uses the following date format as its default:

1995/10/16 02:00:00	(year/month/day   time)

The default timezone is Greenwich Mean Time (GMT), which is also referred to as Coordinated Universal Time (UTC). Dates can be supplied in free format. This lets you specify many different styles. Here are some of the more common ones, which show the same time as in the example above:

6:00 pm lt		(assuming today is Oct. 16, 1995)
2:00 AM, Oct. 16, 1995
Mon Oct 16 18:00:00 1995 LT
Mon Oct 16 18:00:00 PST 1995

The uppercase or lowercase "lt" indicates local time (here, Pacific Standard Time). The third line shows ctime format (plus the "LT"); the fourth line is the date command format.

18.3.6 Specifying States

In some situations, particularly programming environments, you want to know the status of a set of revisions. RCS files are marked by a text string that describes their state. The default state is Exp (experimental). Other common choices include Stab (stable) or Rel (released). These words are user-defined and have no special internal meaning. Several keyword strings include the state in their values. In addition, states can be supplied in options to ci, co, rcs, and rlog.

18.3.7 Standard Options

RCS Version 5.6 defines an environment variable RCSINIT, which is used to set up default options for RCS commands. If you set RCSINIT to a space-separated list of options, they will be prepended to the command-line options you supply to any RCS command. Three options are useful to include in RCSINIT: -q, -V, and -x. They can be thought of as standard options because most RCS commands accept them. Note that -V is new in RCS Version 5 and that -x is new in Version 5.6.

-q[R]

Quiet mode; don't show diagnostic output. R specifies a file revision.

-Vn

Emulate version n of RCS; useful when trading files between systems that run different versions. n can be 3, 4, or 5.

-xsuffixes

Specify an alternate list of suffixes for RCS files. Each suffix is separated by a /. On UNIX systems, RCS files normally end with the characters ,v. The -x option provides a workaround for systems that don't allow a , character in filenames.

For example, when depositing a working file into an RCS file, the command:

ci -x,v/ ch01	(second suffix is blank)

searches in order for the RCS filenames:

RCS/ch01,v
ch01,v
RCS/ch01

Previous: 18.2 Basic Operation | UNIX in a Nutshell: System V Edition | Next: 18.4 Conversion Guide for SCCS Users
18.2 Basic Operation | Book Index | 18.4 Conversion Guide for SCCS Users


[Chapter 18] 18.4 Conversion Guide for SCCS Users

Previous: 18.3 General RCS Specifications Chapter 18
The RCS Utility 		Next: 18.5 Alphabetical Summary of Commands

18.4 Conversion Guide for SCCS Users

SCCS commands have functional equivalents to RCS commands. The following table provides a very general guide for SCCS users:

SCCS | RCS
admin | rcs
admin -i | ci
cdc | rcs -m
delta | ci
get | co
prs | ident or rlog
rmdel | rcs -o
sact | rlog
sccsdiff | rcsdiff
unget | co (with overwrite), or ci with rcs -o
what | ident

Previous: 18.3 General RCS Specifications | UNIX in a Nutshell: System V Edition | Next: 18.5 Alphabetical Summary of Commands
18.3 General RCS Specifications | Book Index | 18.5 Alphabetical Summary of Commands


[Chapter 18] 18.5 Alphabetical Summary of Commands

Previous: 18.4 Conversion Guide for SCCS Users Chapter 18
The RCS Utility 		Next: 19. The make Utility

18.5 Alphabetical Summary of Commands

For details on the syntax of keywords, revision numbers, dates, states, and standard options, refer to the previous discussions.

  • ci
  • co
  • ident
  • merge
  • rcs
  • rcsclean
  • rcsdiff
  • rcsfreeze
  • rcsmerge
  • rlog

Previous: 18.4 Conversion Guide for SCCS Users | UNIX in a Nutshell: System V Edition | Next: 19. The make Utility
18.4 Conversion Guide for SCCS Users | Book Index | 19. The make Utility


[Chapter 19] The make Utility

Previous: 18.5 Alphabetical Summary of Commands Chapter 19 Next: 19.2 Description File Lines

19. The make Utility

Contents:
Command-line Syntax
Description File Lines
Macros
Special Target Names
Sample Default Macros, Suffixes, and Rules

This section presents the following topics:

  • Command-line syntax

  • Description file lines

  • Macros

  • Special target names

  • Sample default macros, suffixes, and rules

For a detailed description of make, refer to the Nutshell Handbook, Managing Projects with make.

The make program generates a sequence of commands for execution by the UNIX shell. It uses a table of file dependencies input by the programmer, and with this information, can perform updating tasks automatically for the user. It can keep track of the sequence of commands that create certain files, and the list of files that require other files to be current before they can operate efficiently. When a program is changed, make can create the proper files with a minimum of effort.

19.1 Command-line Syntax

make [options] [targets] [macro definitions]

Options, targets, and macro definitions can appear in any order. Macros definitions are typed as:

name=string

19.1.1 Options

-e

Environment variables will override any macros defined in description files.

-f file

Use file as the description file; a filename of - denotes standard input. -f can be used more than once to concatenate multiple description files. Default file is makefile or Makefile.

-i

Ignore error codes from commands (same as .IGNORE).

-k

Abandon the current entry when it fails, but keep working with unrelated entries.

-n

Print commands but don't execute (used for testing). -n prints lines even if they begin with @ in the description file.

-p

Print macro definitions, suffixes, and target descriptions.

-q

Query; return 0 if file is up-to-date; nonzero otherwise.

-r

Do not use the default rules.

-s

Do not display command lines (same as .SILENT).

-t

Touch the target files, causing them to be updated.

Previous: 18.5 Alphabetical Summary of Commands | UNIX in a Nutshell: System V Edition | Next: 19.2 Description File Lines
18.5 Alphabetical Summary of Commands | Book Index | 19.2 Description File Lines


[Chapter 19] 19.2 Description File Lines

Previous: 19.1 Command-line Syntax Chapter 19
The make Utility 		Next: 19.3 Macros

19.2 Description File Lines

Instructions in the description file are interpreted as single lines. If an instruction must span more than one input line, use a backslash (\) at the end of the line so that the next line is considered as a continuation. The description file may contain any of the following types of lines:

blank lines

Blank lines are ignored.

comment lines

A pound sign (#) can be used at the beginning of a line or anywhere in the middle. make ignores everything after the #.

dependency lines

Depending on one or more targets, certain commands that follow will be executed. Possible formats include:

targets : prerequisites
targets :: prerequisites

In the first form, subsequent commands are executed if the prerequisites are met. The second form is a variant that lets you specify the same targets on more than one dependency line. In both forms, if no prerequisites are supplied, then subsequent commands are always executed (whenever any of the targets are specified). No tab should precede any targets. (At the end of a dependency line, you can specify a command, preceded by a semicolon; however, commands are typically entered on their own lines, preceded by a tab.)

suffix rules

These specify that files ending with the first suffix can be prerequisites for files ending with the second suffix (assuming the root filenames are the same). Either of these formats can be used:

.suffix.suffix:
.suffix:

The second form means that the root filename depends on the filename with the corresponding suffix. Commands are grouped below the dependency line and are typed on lines that begin with a tab. If a command is preceded by a hyphen (-), make ignores any error returned. If a command is preceded by an at-sign (@), the command line won't echo on the display (unless make is called with -n).

macro definitions

These have the following form:

name = string

Blank space is optional around the =.

include statements

Similar to the C include directive, these have the form:

include file

Previous: 19.1 Command-line Syntax | UNIX in a Nutshell: System V Edition | Next: 19.3 Macros
19.1 Command-line Syntax | Book Index | 19.3 Macros


[Chapter 19] 19.3 Macros

Previous: 19.2 Description File Lines Chapter 19
The make Utility 		Next: 19.4 Special Target Names

19.3 Macros

This subsection summarizes internal macros, modifiers, string substitution, and special macros.

19.3.1 Internal Macros

$?

The list of prerequisites that have been changed more recently than the current target. Can be used only in normal description file entries - not suffix rules.

$@

The name of the current target, except in description file entries for making libraries, where it becomes the library name. Can be used both in normal description file entries and in suffix rules.

$$@

The name of the current target. Can be used only to the right of the colon in dependency lines.

$<

The name of the current prerequisite that has been modified more recently than the current target. Can be used only in suffix rules and in the .DEFAULT: entry.

$*

The name - without the suffix - of the current prerequisite that has been modified more recently than the current target. Can be used only in suffix rules.

$%

The name of the corresponding .o file when the current target is a library module. Can be used both in normal description file entries and in suffix rules.

19.3.2 Macro Modifiers

Macro modifiers are not available in all variants of make.

D

The directory portion of any internal macro name except $?. Valid uses are:

$(*D)   $$(@D)
$(<D)   ${%D)
$(@D)

F

The file portion of any internal macro name except $?. Valid uses are:

$(*F)   $$(@F)
$(<F)   ${%F}
$(@F)

19.3.3 Macro String Substitution

String substitution is not available in all variants of make.

${macro:s1=s2}

Evaluates to the current definition of ${macro}, after substituting the string s1 for every occurrence of s2 that occurs either immediately before a blank or tab, or at the end of the macro definition.

19.3.4 Macros with Special Handling

SHELL

Sets the shell that interprets commands. If this macro isn't defined in the description file, the value depends on your system. Some UNIX implementations use the shell from the user's environment (as with other macros). Other implementations (including SVR4) set the default SHELL to /bin/sh.

VPATH

(Not available in all variants of make.) Specifies a list of directories to search for prerequisites when they aren't found in the current directory.

Previous: 19.2 Description File Lines | UNIX in a Nutshell: System V Edition | Next: 19.4 Special Target Names
19.2 Description File Lines | Book Index | 19.4 Special Target Names


[Chapter 19] 19.4 Special Target Names

Previous: 19.3 Macros Chapter 19
The make Utility 		Next: 19.5 Sample Default Macros, Suffixes, and Rules

19.4 Special Target Names

.DEFAULT:

Commands associated with this target are executed if make can't find any description file entries or suffix rules with which to build a requested target.

.IGNORE:

Ignore error codes. Same as the -i option.

.PRECIOUS:

Files you specify for this target are not removed when you send a signal (such as interrupt) that aborts make, or when a command line in your description file returns an error.

.SILENT:

Execute commands but do not echo them. Same as the -s option.

.SUFFIXES:

Suffixes associated with this target are meaningful in suffixes rules. If no suffixes are listed, the existing list of suffix rules are effectively "turned off."

Previous: 19.3 Macros | UNIX in a Nutshell: System V Edition | Next: 19.5 Sample Default Macros, Suffixes, and Rules
19.3 Macros | Book Index | 19.5 Sample Default Macros, Suffixes, and Rules


[Chapter 19] 19.5 Sample Default Macros, Suffixes, and Rules

Previous: 19.4 Special Target Names Chapter 19
The make Utility 		Next: 20. Program Debugging

19.5 Sample Default Macros, Suffixes, and Rules

EDITOR = /usr/bin/vi
TERM = tvi950ns
SHELL = /bin/sh
PATH = .:/bin:/usr/bin:/usr/fred:/usr/local
LOGNAME = fred
HOME = /usr/fred
GFLAGS =
GET = get
ASFLAGS =
AS = as
FFLAGS =
FC = f77
CFLAGS = -O
CC = cc
LDFLAGS =
LD = ld
LFLAGS =
LEX = lex
YFLAGS =
YACC = yacc
MAKE = make
$ = $
MAKEFLAGS = b

.h~.h:
     $(GET) $(GFLAGS) -p $< > $*.h

.s~.a:
     $(GET) $(GFLAGS) -p $< > $*.s
     $(AS) $(ASFLAGS) -o $*.o $*.s
     ar rv $@ $*.o
     -rm -f $*.[so]

.r~.a:
     $(GET) $(GFLAGS) -p $< > $*.r
     $(FC) -c $(FFLAGS) $*.r
     ar rv $@ $*.o
     rm -f $*.[ro]

.e~.a:
     $(GET) $(GFLAGS) -p $< > $*.e
     $(FC) -c $(FFLAGS) $*.e
     ar rv $@ $*.o
     rm -f $*.[eo]

.f~.a:
     $(GET) $(GFLAGS) -p $< > $*.f
     $(FC) -c $(FFLAGS) $*.f
     ar rv $@ $*.o
     rm -f $*.[fo]

.r.a:
     $(FC) -c $(FFLAGS) $<
     ar rv $@ $*.o
     rm -f $*.o

.e.a:
     $(FC) -c $(FFLAGS) $<
     ar rv $@ $*.o
     rm -f $*.o

.f.a:
     $(FC) -c $(FFLAGS) $<
     ar rv $@ $*.o
     rm -f $*.o

.c~.a:
     $(GET) $(GFLAGS) -p $< > $*.c
     $(CC) -c $(CFLAGS) $*.c
     ar rv $@ $*.o
     rm -f $*.[co]

.c.a:
     $(CC) -c $(CFLAGS) $<
     ar rv $@ $*.o
     rm -f $*.o

.l.c:
     $(LEX) $<
     mv lex.yy.c $@

.y~.c:
     $(GET) $(GFLAGS) -p $< > $*.y
     $(YACC) $(YFLAGS) $*.y
     mv y.tab.c $*.c
     -rm -f $*.y

.y.c:
     $(YACC) $(YFLAGS) $<
     mv y.tab.c $@

.l~.o:
     $(GET) $(GFLAGS) -p $< > $*.l
     $(LEX) $(LFLAGS) $*.l
     $(CC) $(CFLAGS) -c lex.yy.c
     rm -f lex.yy.c $*.l
     mv lex.yy.o $*.o

.l.o:
     $(LEX) $(LFLAGS) $<
     $(CC) $(CFLAGS) -c lex.yy.c
     rm lex.yy.c
     mv lex.yy.o $@

.y~.o:
     $(GET) $(GFLAGS) -p $< > $*.y
     $(YACC) $(YFLAGS) $*.y
     $(CC) $(CFLAGS) -c y.tab.c
     rm -f y.tab.c $*.y
     mv y.tab.o $*.o

.y.o:
     $(YACC) $(YFLAGS) $<
     $(CC) $(CFLAGS) -c y.tab.c
     rm y.tab.c
     mv y.tab.o $@

.s~.o:
     $(GET) $(GFLAGS) -p $< > $*.s
     $(AS) $(ASFLAGS) -o $*.o $*.s
     -rm -f $*.s

.s.o:
     $(AS) $(ASFLAGS) -o $@ $<

.r~.o:
     $(GET) $(GFLAGS) -p $< > $*.r
     $(FC) $(FFLAGS) -c $*.r
     -rm -f $*.r

.e~.e:
     $(GET) $(GFLAGS) -p $< > $*.e

.e~.o:
     $(GET) $(GFLAGS) -p $< > $*.e
     $(FC) $(FFLAGS) -c $*.e
     -rm -f $*.e

.f~.f:
     $(GET) $(GFLAGS) -p $< > $*.f

.f~.o:
     $(GET) $(GFLAGS) -p $< > $*.f
     $(FC) $(FFLAGS) -c $*.f
     -rm -f $*.f

.r.o:
     $(FC) $(FFLAGS) -c $<

.e.o:
     $(FC) $(FFLAGS) -c $<

.f.o:
     $(FC) $(FFLAGS) -c $<

.c~.c:
     $(GET) $(GFLAGS) -p $< > $*.c

.c~.o:
     $(GET) $(GFLAGS) -p $< > $*.c
     $(CC) $(CFLAGS) -c $*.c
     -rm -f $*.c

.c.o:
     $(CC) $(CFLAGS) -c $<

.sh~:
     $(GET) $(GFLAGS) -p $< > $*.sh
     cp $*.sh $*
     -rm -f $*.sh

.sh:
     cp $< $@

.r~:
     $(GET) $(GFLAGS) -p $< > $*.r
     $(FC) -n $(FFLAGS) $*.r -o $*
     -rm -f $*.r

.r:
     $(FC) $(FFLAGS) $(LDFLAGS) $< -o $@

.e~:
     $(GET) $(GFLAGS) -p $< > $*.e
     $(FC) -n $(FFLAGS) $*.e -o $*
     -rm -f $*.e

.e:
     $(FC) $(FFLAGS) $(LDFLAGS) $< -o $@

.f~:
     $(GET) $(GFLAGS) -p $< > $*.f
     $(FC) -n $(FFLAGS) $*.f -o $*
     -rm -f $*.f

.f:
     $(FC) $(FFLAGS) $(LDFLAGS) $< -o $@

.c~:
     $(GET) $(GFLAGS) -p $< > $*.c
     $(CC) -n $(CFLAGS) $*.c -o $*
     -rm -f $*.c

.c:
     $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@

.SUFFIXES:
&     .o  .c  .c~  .f  .f~  .e  .e~  .r  .r~
&     .y  .y~  .l  .l~  .s  .s~  .sh  .sh~  .h  .h~

Previous: 19.4 Special Target Names | UNIX in a Nutshell: System V Edition | Next: 20. Program Debugging
19.4 Special Target Names | Book Index | 20. Program Debugging


[Chapter 20] Program Debugging

Previous: 19.5 Sample Default Macros, Suffixes, and Rules Chapter 20 Next: 20.2 The Dbx Debugger

20. Program Debugging

Contents:
The Sdb Debugger
The Dbx Debugger

This section presents the debugging utilities for the UNIX environment:

  • Sdb (available in SVR4 but not Solaris 2.0)

  • Dbx (Solaris 2.0 only)

These debuggers take an executable object file and its corefile-the core image file produced when objfile is executed. The debuggers then provide a controlled environment for the execution of the program.

If objfile and corefile are not specified, a.out is taken as the default object file and core as the default core image file.

Each debugging utility is listed among the UNIX commands in Section 2 of this guide.

20.1 The Sdb Debugger

Sdb, the symbolic debugger, is used for checking assembly programs, executable C and FORTRAN programs, and core files resulting from aborted programs. It has the following command-line syntax:

sdb [options] [objfile [corefile [dir]]]

A - in place of corefile will force sdb to ignore any core image file.

20.1.1 Options

-e

Ignore symbolic data; treat addresses as file offsets.

-s n

Don't stop processes that receive signal number n. See the signal system call for values of n. -s may be used more than once.

-V

Print version information (and exit if no objfile is given).

-w

Make objfile and corefile writable.

-W

Suppress warning messages about older files.

20.1.2 Command Specifiers

In the "Commands" section below, commands use the specifiers m, l, and n. m is the display format of an address. (Addresses are specified by a variable or a line number.) l is the address length. n stands for the line number.

20.1.2.1 Values for m

a

Characters starting at variable's address.

c

Character.

d

Decimal.

f

32-bit floating.

g

64-bit double precision floating.

i

Disassemble machine-language instructions; print address using numbers and symbols.

I

Same as i, but print address using numbers only.

o

Octal.

p

Pointer to procedure.

s

Print character(s) at address pointed to by (string pointer) variable.

u

Unsigned decimal.

x

Hexadecimal.

20.1.2.2 Values for l

Length specifiers are meaningful only with m values of c, d, o, u, or x.

b

One byte.

h

Two bytes (half word).

l

Four bytes (long word).

20.1.3 Commands

Refer to the previous specifiers when reviewing the sdb commands, which are grouped below:

20.1.4 Formatted Printing

t | Print a stack trace.
T | Print the top line of the stack trace.
variable/clm | Print variable according to length l and format m. Number c specifies how much memory (in units of l) to display.
n?lm variable:?lm | Print from a.out and procedure variable according to length l and format m. Default lm is i.
variable=lm n=lm number=lm | Print the address of variable or line number n, in the format specified by l and m. Use the last form to convert number to the format specified by l and m. Default lm is lx.
variable!value | Assign value to variable.
x | Display the machine registers and the machine instructions.
X | Display the machine instructions.

20.1.5 Examining the Source

e | Print name of current file.
eproc | Set current file to file containing procedure proc.
efile | Set current file to file.
edir/ | Append directory dir to directory list.
p | Print current line.
w | Print ten lines surrounding the current line.
z | Print ten lines (starting at current); reset current line to last line.
/regexp/ | Search ahead for regular expression regexp.
?regexp? | Search back for regular expression regexp.
n | Set current line to n and print it.
count+ | Advance count lines; print new current line.
count- | Go back count lines; print new current line.

20.1.6 Executing the Source

n a | Set a breakpoint at line number n and inform the user.
[n] b commands | Set breakpoint at line number n and optionally execute sdb commands (separated by ;) at breakpoint.
[n] c count | Continue after a breakpoint or, if count is given, stop after count breakpoints. If n is specified, set a temporary breakpoint at line number n.
[n] C count | Same as c, but reactivate any signal that stopped program.
n g count | Continue at line number n after a breakpoint. If count is given, ignore count breakpoints.
[count] r args | Run the program with the specified arguments. Ignore count breakpoints.
[count] r | Rerun the program with the previously specified arguments. Ignore count breakpoints.
[count] R | Run the program with the no arguments. Ignore count breakpoints.
[level] [v] | This command is used when single-stepping via s, S, or m. v turns off verbose mode; omit v to turn on verbose mode. If level is omitted, print only source file or function name when either changes; otherwise, set level to 1 (print C source lines before execution) or 2 or higher (print C source lines and assembler statements).
proc(a1,a2,...) | Execute procedure proc with arguments a1, a2, etc. Arguments can be constants, local variable names, or register names. Append /m in order to print the returned value in format m (default is d).

20.1.7 Breakpoint and Program Control

B | Print active breakpoints.
[n] d | Delete breakpoint at line number n.
D | Remove all breakpoints.
i count | Single-step count machine-language instructions.
I count | Same as i, but reactivate any signal that stopped program.
k | Kill the program you're debugging.
l | Print the previous line executed.
M | Print the address maps.
var$m count addr:m count | Single-step count lines until the specified variable or address is modified. Omitting count specifies an infinite count.
q | Exit sdb.
s [count] | Single-step count lines.
S [count] | Same as s, but skip called functions.

20.1.8 Miscellaneous Commands

#text | Supply a text comment ignored by sdb.
!cmd | Execute cmd with sh.
newline | Display the next line or memory location, or disassemble the next instruction.
EOF | Scroll the display ten lines.
< file | Execute commands contained in file.
string | Print a quoted string. C escape characters are recognized.
V | Print the sdb version number.

Previous: 19.5 Sample Default Macros, Suffixes, and Rules | UNIX in a Nutshell: System V Edition | Next: 20.2 The Dbx Debugger
19.5 Sample Default Macros, Suffixes, and Rules | Book Index | 20.2 The Dbx Debugger


[Chapter 20] 20.2 The Dbx Debugger

Previous: 20.1 The Sdb Debugger Chapter 20
Program Debugging 		Next: 21. ASCII Character Set

20.2 The Dbx Debugger

Dbx can be used to debug programs written in C, C++, FORTRAN, and Pascal. Dbx commands can be stored in a start-up .dbxinit file that resides in the current directory or in the user's home directory. These commands are executed just before reading the symbol table. The command-line syntax for dbx is as follows:

dbx [options] [objfile [corefile]]

20.2.1 Options

-c cmd

Run dbx cmd after initialization.

-C

Collect profile data for debugged program.

-e

Echo input commands on standard output.

-i

Act as if standard input is a terminal.

-I dir

Add dir to the directory search path. The dbx command use resets the search path.

-kbd

Debug a program that puts the keyboard in up-down translation mode.

-P file_des

Pipe output to the debugger command via file descriptor file_des. debugger passes this option automatically.

-q

Suppress messages during loading (useful during auto-traceback).

-r

Execute objfile right away, then wait for user response from the keyboard.

-s file

Read initialization commands from start-up file.

-sr tmp

Like -s, but then delete start-up file (tmp).

- pid

Debug a currently running program whose process ID is pid (used mainly for auto-traceback).

20.2.2 Alphabetical Summary of Commands

Within dbx, the most useful commands are run, where, print, and stop. Use help to summarize the available commands. In the listing below, the term func is used to represent either a procedure or a function.

  • alias
  • assign
  • call
  • catch
  • cd
  • clear
  • cont
  • CTRL-C
  • dbxenv
  • debug
  • delete
  • detach
  • display
  • down
  • dump
  • edit
  • file
  • func
  • help
  • history
  • ignore
  • kill
  • language
  • list
  • make
  • modules
  • next
  • nexti
  • print
  • pwd
  • quit
  • replay
  • rerun
  • restore
  • return
  • run
  • save
  • set
  • setenv
  • sh
  • source
  • status
  • step
  • step
  • stepi
  • stop
  • stopi
  • trace
  • tracei
  • unalias
  • undisplay
  • unset
  • up
  • use
  • whatis
  • when
  • where
  • whereis
  • which
  • search
  • addr1/
  • address

Previous: 20.1 The Sdb Debugger | UNIX in a Nutshell: System V Edition | Next: 21. ASCII Character Set
20.1 The Sdb Debugger | Book Index | 21. ASCII Character Set


[Chapter 21] ASCII Character Set

Previous: 20.2 The Dbx Debugger Chapter 21

21. ASCII Character Set

This section presents the set of ASCII characters, along with their equivalent values in decimal, octal, and hexadecimal. The first table shows nonprinting characters. This table would be useful when you need to represent nonprinting characters in some printed form, such as octal. For example, the echo and tr commands let you specify characters using octal values of the form \nnn. Also, the od command can be used to display nonprinting characters in a variety of forms.

The second table shows printing characters. This table would be useful when using the commands mentioned above, but also when specifying a range of characters in a pattern-matching construct.

Table 21.1: Nonprinting Characters
Decimal | Octal | Hex | Character | Remark
0 | 000 | 00 | CTRL-@ | NUL (Null prompt)
1 | 001 | 01 | CTRL-A | SOH (Start of heading)
2 | 002 | 02 | CTRL-B | STX (Start of text)
3 | 003 | 03 | CTRL-C | ETX (End of text)
4 | 004 | 04 | CTRL-D | EOT (End of transmission)
5 | 005 | 05 | CTRL-E | ENQ (Enquiry)
6 | 006 | 06 | CTRL-F | ACK (Acknowledge)
7 | 007 | 07 | CTRL-G | BEL (Bell)
8 | 010 | 08 | CTRL-H | BS (Backspace)
9 | 011 | 09 | CTRL-I | HT (Horizontal tab)
10 | 012 | 0A | CTRL-J | LF (Linefeed)
11 | 013 | 0B | CTRL-K | VT (Vertical tab)
12 | 014 | 0C | CTRL-L | NP (New page) or FF (Formfeed)
13 | 015 | 0D | CTRL-M | CR (Carriage return)
14 | 016 | 0E | CTRL-N | SO (Shift out)
15 | 017 | 0F | CTRL-O | SI (Shift in)
16 | 020 | 10 | CTRL-P | DLE (Data link escape)
17 | 021 | 11 | CTRL-Q | DC1 (X-ON)
18 | 022 | 12 | CTRL-R | DC2
19 | 023 | 13 | CTRL-S | DC3 (X-OFF)
20 | 024 | 14 | CTRL-T | DC4
21 | 025 | 15 | CTRL-U | NAK (No acknowledge)
22 | 026 | 16 | CTRL-V | SYN (Synchronous idle)
23 | 027 | 17 | CTRL-W | ETB (End transmission blocks)
24 | 030 | 18 | CTRL-X | CAN (Cancel)
25 | 031 | 19 | CTRL-Y | EM (End of medium)
26 | 032 | 1A | CTRL-Z | SUB (Substitute)
27 | 033 | 1B | CTRL-[ | ESC (Escape)
28 | 034 | 1C | CTRL-\ | FS (File separator)
29 | 035 | 1D | CTRL-] | GS (Group separator)
30 | 036 | 1E | CTRL-^ | RS (Record separator)
31 | 037 | 1F | CTRL-_ | US (Unit separator)
127 | 177 | 7F |  | DEL (Delete or rubout)
Table 21.2: Printing Characters
Decimal | Octal | Hex | Character | Remark
32 | 040 | 20 |  | Space
33 | 041 | 21 | ! | Exclamation Point
34 | 042 | 22 | " | Double quote
35 | 043 | 23 | # | Sharp Sign
36 | 044 | 24 | $ | Dollar Sign
37 | 045 | 25 | % | Percent Sign
38 | 046 | 26 | & | Ampersand
39 | 047 | 27 | ' | Apostrophe
40 | 050 | 28 | ( | Left Parenthesis
41 | 051 | 29 | ) | Right Parenthesis
42 | 052 | 2A | * | Asterisk
43 | 053 | 2B | + | Plus Sign
44 | 054 | 2C | , | Comma
45 | 055 | 2D | - | Hyphen
46 | 056 | 2E | . | Period
47 | 057 | 2F | / | Slash (Virgule)
48 | 060 | 30 | 0 |
49 | 061 | 31 | 1 |
50 | 062 | 32 | 2 |
51 | 063 | 33 | 3 |
52 | 064 | 34 | 4 |
53 | 065 | 35 | 5 |
54 | 066 | 36 | 6 |
55 | 067 | 37 | 7 |
56 | 070 | 38 | 8 |
57 | 071 | 39 | 9 |
58 | 072 | 3A | : | Colon
59 | 073 | 3B | ; | Semicolon
60 | 074 | 3C | < | Left Angle Bracket
61 | 075 | 3D | &= | Equal Sign
62 | 076 | 3E | > | Right Angle Bracket
63 | 077 | 3F | ? | Question Mark
64 | 100 | 40 | @ | "At" Sign
65 | 101 | 41 | A |
66 | 102 | 42 | B |
67 | 103 | 43 | C |
68 | 104 | 44 | D |
69 | 105 | 45 | E |
70 | 106 | 46 | F |
71 | 107 | 47 | G |
72 | 110 | 48 | H |
73 | 111 | 49 | I |
74 | 112 | 4A | J |
75 | 113 | 4B | K |
76 | 114 | 4C | L |
77 | 115 | 4D | M |
78 | 116 | 4E | N |
79 | 117 | 4F | O |
80 | 120 | 50 | P |
81 | 121 | 51 | Q |
82 | 122 | 52 | R |
83 | 123 | 53 | S |
84 | 124 | 54 | T |
85 | 125 | 55 | U |
86 | 126 | 56 | V |
87 | 127 | 57 | W |
88 | 130 | 58 | X |
89 | 131 | 59 | Y |
90 | 132 | 5A | Z |
91 | 133 | 5B | [ | Left Square Bracket
92 | 134 | 5C | \ | Backslash
93 | 135 | 5D | ] | Right Square Bracket
94 | 136 | 5E | &^ | Caret
95 | 137 | 5F | &_ | Underscore
96 | 140 | 60 | ` | Back Quote
97 | 141 | 61 | a |
98 | 142 | 62 | b |
99 | 143 | 63 | c |
100 | 144 | 64 | d |
101 | 145 | 65 | e |
102 | 146 | 66 | f |
103 | 147 | 67 | g |
104 | 150 | 68 | h |
105 | 151 | 69 | i |
106 | 152 | 6A | j |
107 | 153 | 6B | k |
108 | 154 | 6C | l |
109 | 155 | 6D | m |
110 | 156 | 6E | n |
111 | 157 | 6F | o |
112 | 160 | 70 | p |
113 | 161 | 71 | q |
114 | 162 | 72 | r |
115 | 163 | 73 | s |
116 | 164 | 74 | t |
117 | 165 | 75 | u |
118 | 166 | 76 | v |
119 | 167 | 77 | w |
120 | 170 | 78 | x |
121 | 171 | 79 | y |
122 | 172 | 7A | z |
123 | 173 | 7B | { | Left Curly Brace
124 | 174 | 7C | | | Vertical Bar
125 | 175 | 7D | } | Right Curly Brace
126 | 176 | 7E | ~ | Tilde

Previous: 20.2 The Dbx Debugger | UNIX in a Nutshell: System V Edition
20.2 The Dbx Debugger | Book Index


By Daniel Gilly & the Staff of O'Reilly & Associates; ISBN 1-56592-001-5, 444 pages.
Second Edition, June 1992.
(See the catalog page for this book.)

Search the text of UNIX in a Nutshell: System V Edition.

Index

Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Table of Contents

Preface
Chapter 1: Introduction
Chapter 2: UNIX Commands
Chapter 3: The UNIX Shell: An Overview
Chapter 4: The Bourne Shell and Korn Shell
Chapter 5: The C Shell
Chapter 6: Pattern Matching
Chapter 7: The Emacs Editor
Chapter 8: The Vi Editor
Chapter 9: The Ex Editor
Chapter 10: The Sed Editor
Chapter 11: The Awk Scripting Language
Chapter 12: Nroff and Troff
Chapter 13: mm Macros
Chapter 14: ms Macros
Chapter 15: me Macros
Chapter 16: Preprocessors
Chapter 17: The SCCS Utility
Chapter 18: The RCS Utility
Chapter 19: The make Utility
Chapter 20: Program Debugging
Chapter 21: ASCII Character Set

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System

Copyright © 1998 O'Reilly & Associates. All Rights Reserved.


Preface

Contents:
Audience
Scope of This Book
Conventions
Acknowledgments
We'd Like to Hear From You

It may be a cliche, but it's true: the second edition of UNIX in a Nutshell (for System V) really is "bigger and better." Besides having a whole new appearance, the book has been revised for SVR4 and Solaris 2.0. Major additions include:

  • New SVR4 commands and options.

  • Selected BSD-derived commands from the compatibility packages.

  • Additional features specifically from Solaris 2.0.

  • Coverage of the Korn shell.

  • Sections on GNU Emacs and RCS (which aren't in standard SVR4).

  • An index to the commands described in this book.

  • Useful examples throughout the book.

Audience

This quick reference should be of interest to UNIX users and UNIX programmers, as well as to anyone (such as a system administrator) who might offer direct support to users and programmers. The presentation is geared mainly toward people who are familiar with the UNIX system - that is, you know what you want to do, and you even have some idea how to do it. You just need a reminder about the details. For example, if you want to remove the third field from a database, you might think, "I know I can use the cut command, but what are the options?" In many cases, specific examples are provided to show how a command is used.

This quick reference (or "quick ref") might also help people who are familiar with some aspects of UNIX but not with others. Many sections include an overview of the particular topic. While this isn't meant to be comprehensive, it's usually sufficient to get you started in unfamiliar territory.

And some of you may be coming from a UNIX system that runs the BSD or SunOS 4.1 version. To help with such a transition, SVR4 and Solaris 2.0 include a group of "compatibility" commands, many of which are presented in this guide.

Finally, if you're new to the UNIX operating system, and you're feeling bold, you might appreciate this book as a quick tour of what UNIX has to offer. The "Beginner's Guide" in Section 1 can point you to the most useful commands, and you'll find brief examples of how to use them, but take note: this book should not be used in place of a good beginner's tutorial on UNIX. This quick ref should be a supplement, not a substitute.

UNIX in a Nutshell: System V Edition | Next: Scope of This Book
Book Index | Scope of This Book


[Preface] Scope of This Book

Previous: Audience Preface Next: Conventions

Scope of This Book

The quick ref is divided into five parts:

  • Part I (Sections 1 through 5) describes the syntax and options for UNIX commands and for the Bourne, Korn, and C shells.

  • Part II (Sections 6 through 11) presents various editing tools and describes their command set (alphabetically and by group). Part II begins with a review of pattern matching, including examples geared toward specific editors.

  • Part III (Sections 12 through 16) describes the nroff/troff text formatting programs, related macro packages, and the preprocessors tbl, eqn, and pic.

  • Part IV (Sections 17 through 20) summarizes the UNIX utilities for software development - SCCS, RCS, make, and program debuggers sdb and dbx.

  • Part V contains two loose ends: a table of ASCII characters and equivalent values, and a command index to help you locate the commands presented in this book.

Previous: Audience | UNIX in a Nutshell: System V Edition | Next: Conventions
Audience | Book Index | Conventions


[Preface] Conventions

Previous: Scope of This Book Preface Next: Acknowledgments

Conventions

The quick ref follows certain typographic conventions, outlined below:

Bold

is used for directories, filenames, commands, and options. All terms shown in bold are typed literally.

Italic

is used to show generic arguments and options; these should be replaced with user-supplied values. Italic is also used to highlight comments in examples.

Constant Width

is used to show the contents of files or the output from commands.

Constant Bold

is used in examples and tables to show commands or other text that should be typed literally by the user.

Constant Italic

is used in examples and tables to show generic text; these should be replaced with user-supplied values.

%, $

are used in some examples as the C shell prompt (%) and as the Bourne shell or Korn shell prompt ($).

[ ]

surround optional elements in a description of syntax. (The brackets themselves should never be typed.) Note that many commands show the argument [files]. If a filename is omitted, standard input (i.e., the keyboard) is assumed. End with an end-of-file character.

EOF

indicates the end-of-file character (normally CTRL-D).

|

is used in syntax descriptions to separate items for which only one alternative may be chosen at a time.

A final word about syntax. In many cases, the space between an option and its argument can be omitted. In other cases, the spacing (or lack of spacing) must be followed strictly. For example, -w n (no intervening space) might be interpreted differently from -w n. It's important to notice the spacing used in option syntax.

Previous: Scope of This Book | UNIX in a Nutshell: System V Edition | Next: Acknowledgments
Scope of This Book | Book Index | Acknowledgments


[Preface] Acknowledgments

Previous: Conventions Preface Next: We'd Like to Hear From You

Acknowledgments

Many people helped this book along the way. The first edition resulted from the efforts of the following staff members of O'Reilly & Associates: Jean Diaz, Dale Dougherty, Daniel Gilly, Linda Mui, Tim O'Reilly, Thomas Van Raalte, Linda Walsh, Sue Willing, and Donna Woonteiler.

The second edition has a new cover and new interior layout, designed by Edie Freedman. Arthur Saarinen drew the referee figures. Chris Reilley and Jeff Robbins assisted with graphics. The manuscript was formatted using troff macros that were implemented by Linda Mui and Lenny Muellner, and the manuscript was prepared through the efforts of Donna Woonteiler, Sue Willing, and especially Rosanne Wagger. Christine Kenney and Peter Mui were valuable resources, tracking down useful information and passing it along.

Special thanks to the technical reviewers for reading the drafts and fielding all kinds of questions; the book has profited greatly from the comments of Tan Bronson (Microvation Consultants), Peter van der Linden, and Mike Loukides (O'Reilly & Associates).

Previous: Conventions | UNIX in a Nutshell: System V Edition | Next: We'd Like to Hear From You
Conventions | Book Index | We'd Like to Hear From You


[Preface] We'd Like to Hear From You

Previous: Acknowledgments Preface Next: 1. Introduction

We'd Like to Hear From You

We have tested and verified all of the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). Please let us know about any errors you find, as well as your suggestions for future editions, by .hw writing writing:

O'Reilly & Associates, Inc.
101 Morris Street
Sebastopol, CA 95472
1-800-998-9938 (in the US or Canada)
1-707-829-0515 (international/local)
1-707-829-0104 (FAX)

You can also send us messages electronically. To be put on the mailing list or request a catalog, send email to:

info@oreilly.com

To ask technical questions or comment on the book, send email to:

bookquestions@oreilly.com

Previous: Acknowledgments | UNIX in a Nutshell: System V Edition | Next: 1. Introduction
Acknowledgments | Book Index | 1. Introduction