Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's what I do:

$ echo '1
3' | sed -n '

Is it expected behavior? I'm running gnu sed 4.2.1.

share|improve this question
up vote 4 down vote accepted

excerpting from the info page: "output the lines of text which follow this command ... A new cycle is started after this command is done"

Presumably then, the last x command is never used.

share|improve this answer
+1 The fact is not mentioned in the man page. – choroba Jun 6 '14 at 11:47
Indeed, I was judging from man page. – x-yuri Jun 6 '14 at 11:51
A link to the manual would be apt: gnu.org/software/sed/manual/sed.html – glenn jackman Jun 6 '14 at 13:45
This behavior for the c command is also specified by POSIX: "Delete the pattern space. With a 0 or 1 address or at the end of a 2-address range, place text on the output and start the next cycle." – jw013 Jun 6 '14 at 14:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.