Previous: , Up: Invoking sed   [Contents][Index]


2.3 Exit status

An exit status of zero indicates success, and a nonzero value indicates failure. GNU sed returns the following exit status error values:

0

Successful completion.

1

Invalid command, invalid syntax, invalid regular expression or a GNU sed extension command used with --posix.

2

One or more of the input file specified on the command line could not be opened (e.g. if a file is not found, or read permission is denied). Processing continued with other files.

4

An I/O error, or a serious processing error during runtime, GNU sed aborted immediately.

Additionally, the commands q and Q can be used to terminate sed with a custom exit code value (this is a GNU sed extension):

$ echo | sed 'Q42' ; echo $?
42