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*

9
  • I would prefer to use sed only, as requested in the question. Commented Nov 11, 2021 at 17:51
  • @virtualdj ok, I'll try that, could you explain why sed only? Commented Nov 11, 2021 at 17:52
  • For the same reasons of the original question (unix.stackexchange.com/q/107387/188792), i.e. I have a system with limited binaries available. Commented Nov 11, 2021 at 17:53
  • Upvoters! The sed solution is from @Quasímodo, they added it instead of posting their own answer. Many thanks to they. Commented Nov 11, 2021 at 21:13
  • 1
    @schrodiger, I'm glad it was useful. I now realize the q command is not even needed, sed ':a;${s/^/# /;s/\n/&# /g;};N;4,$D;ba' file is enough because N works like q if called from the last line of the file. Commented Nov 12, 2021 at 15:16