Unix Power ToolsUnix Power ToolsSearch this book

34.23. Dangers of the sed Quit Command

The sed quit command, q (Section 34.22), 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



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.