h # Copy Pattern space (line just read) to Hold space. n # Read the next line of input into Pattern space. p # Output Pattern space. g # Copy Hold space to Pattern space. p # Output Pattern space (which now holds the previous line).