4.5. Error Messages and Exit Status

When sed encounters a syntax error, it sends a pretty straightforward error message to standard error, but if it cannot figure out what you did wrong, sed gets “garbled,” which we could guess means confused. The exit status that sed returns to the shell, if its syntax is error-free, is a zero for success and a nonzero integer for failure.[2]

[2] For a complete list of diagnostics, see the UNIX man page for sed.

Example 4.3.
1   % sed '1,3v ' file
    sed: Unrecognized command: 1,3v
    % echo $status (echo $?
					if using Korn or Bourne shell)
    2

2   % sed '/^John' file
					sed: Illegal or missing delimiter: /^John

3   % sed 's/134345/g' file
					sed: Ending delimiter missing on substitution: s/134345/g
				

EXPLANATION

  1. The v command is ...

Get UNIX® Shells by Example, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.