On Thu, Mar 27, 2025 at 01:21:03AM -0400, Eric Sunshine wrote: > > I think just "/foo/p;q" works on GNU sed, but no idea if it does > > elsewhere. What you wrote seems the safest. > > That's not quite the same, though. The patternless `q` will cause > `sed` to terminate upon reading the first line of input, not upon the > first line which contains " version ". This matters, for instance, if > the first line output by `$CC -v` is not the version string (i.e. it > might be a copyright notice). Oh, duh, you're right. I even tested to make sure were still quitting after matching, but of course that is because we were quitting even when _not_ matching. For some reason I also thought /foo/pq would work, but it doesn't. I wonder if it used to under some implementations, or if I'm simply going senile. (The point still remains that what you wrote is the correct thing). -Peff