Command Description
b label
  • Jump to label; if label is not specified, then jump to the end of the script.
  • This is an unconditional branch; see command 't' for a conditional one.
d Clear the contents of pattern space and start a new cycle.
D Delete the first line from pattern space.
Control then passes to the top of the script.
If command 'D' empties the pattern space, a new line will be read in;
otherwise, no new line will be read in.
g Overwrite the contents of pattern space with hold space.
G Append the contents of hold space to pattern space,
separate them by a newline character.
h Overwrite the contents of hold space with pattern space.
H Append the contents of pattern space to hold space,
separate them by a newline character.
n Print the contents of pattern space and overwrite it with next line.
Control passes to the command following this 'n'.
N Append next line to pattern space.
Next line is separated from the original pattern space by a newline character.
p Print the contents of pattern space.
P Print the first line of pattern space.
q Print the contents of pattern space then exit.
t
  • Jump to label if any substitution has been made on the pattern space since the most recent reading of input line or execution of command 't'.
  • If label is not specified, then jump to the end of the script.
  • This is a conditional branch; see command 'b' for a conditional one.
w Write the contents of pattern space to the file specified after the w command.
x Exchange the contents of pattern space and hold space.