Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Thanks, that cleared it to me also. My error was that I understood ! was connected to d, not 123. Commented Nov 18, 2011 at 8:44
  • @Gilles: missing the braces {d;q;}, shouldn't q apply to every line (so only the first)? Commented Nov 18, 2011 at 9:31
  • 1
    @enzotib q applies to every line where it's executed. But when the line number is not 123, the d command is executed, and its meaning is to skip immediately to the next input line. Commented Nov 18, 2011 at 10:18
  • Crystal clear explanation Commented Jan 24, 2014 at 15:44
  • Essentially it does the same as sed -n 123p (prints the same output) except it stops after line 123 rather than processing potentially thousands more lines that it will never do anything with anyways. Commented Feb 15, 2016 at 7:33