2016-09-13 There's an interesting detail in sed, which irritated me today. I wanted to cut off the reminder of a file, thus I used: sed '/end marker/q' This cuts off everything *after* the marker. Hence, I thought I'd just add a `d' to delete the marker line before I quit: sed '/end marker/{d;q}' But that doesn't work! It is equivalent to omiting the `q'. The reason it does not quit lies in the `d' command: d Delete pattern space. Start next cycle. It instantly starts the next cycle. A workaround, which will do almost, is this: sed '/end marker/{x;q}' It exchanges the pattern and hold spaces, and as the hold space was empty, the pattern space becomes empty ... and an empty line is printed. But, well, this is not exactly the same as not print- ing anything. The correct way to do it is: sed -n '/end marker/q;p' This should be considered an idiom, I suppose. http://marmaro.de/lue/ markus schnalke