UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 34.21 Uses of the sed Quit Command Chapter 34
The sed Stream Editor
Next: 34.23 sed Newlines, Quoting, and Backslashes in a Shell Script
 

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


Previous: 34.21 Uses of the sed Quit Command UNIX Power ToolsNext: 34.23 sed Newlines, Quoting, and Backslashes in a Shell Script
34.21 Uses of the sed Quit Command Book Index34.23 sed Newlines, Quoting, and Backslashes in a Shell Script

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