sed: Exit status

1 
1 2.3 Exit status
1 ===============
1 
1 An exit status of zero indicates success, and a nonzero value indicates
1 failure.  GNU 'sed' returns the following exit status error values:
1 
1 0
1      Successful completion.
1 
1 1
1      Invalid command, invalid syntax, invalid regular expression or a
1      GNU 'sed' extension command used with '--posix'.
1 
1 2
1      One or more of the input file specified on the command line could
1      not be opened (e.g.  if a file is not found, or read permission is
1      denied).  Processing continued with other files.
1 
1 4
1      An I/O error, or a serious processing error during runtime, GNU
1      'sed' aborted immediately.
1 
1    Additionally, the commands 'q' and 'Q' can be used to terminate 'sed'
1 with a custom exit code value (this is a GNU 'sed' extension):
1 
1      $ echo | sed 'Q42' ; echo $?
1      42
1