[Chapter 34] 34.22 Dangers of the sed Quit Command
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:47:34Z

#

| Chapter 34 The sed Stream Editor |

## 34.22 Dangers of the sed Quit Command

The sed quit command, q (34.21), is very useful for getting sed to stop processing any more input once you've done what you want.

However, you need to be very careful not to use q in any sed script that writes its edits back to the original file. After q is executed, no further output is produced. It should not be used in any case where you want to edit the front of the file and pass the remainder through unchanged. Using q in this case is a dangerous beginner's mistake.

- TOR

34.21 Uses of the sed Quit Command |  | 34.23 sed Newlines, Quoting, and Backslashes in a Shell Script