This question already has an answer here:

What is the command to: Modify the "cat" command to automatically number paragraphs. These are separated by a single blank line.

marked as duplicate by Kusalananda, Jeff Schaller, GAD3R, roaima, Barmar Jan 27 '17 at 20:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Maybe something like passing cat -n to sed or something along those lines? – Alexej Magura Jan 27 '17 at 17:38
  • Have you considered reading the documentation? Try man cat in a terminal and see if that gets you somewhere to start with. – roaima Jan 27 '17 at 20:12
  • We have been confused. The link of Kusalananda does cover your question or you need something different? – George Vasiliou Jan 27 '17 at 20:34
  • I don't think he really means modifying the cat command itself, but process the output of it. – Barmar Jan 27 '17 at 20:45
  • This is the link i'm talking about . This question seems a duplicate. unix.stackexchange.com/questions/265779/… – George Vasiliou Jan 27 '17 at 21:16

If you want to actually modify the cat command, the source can be found here; feel free to check it out and do whatever you like with it for your local compilation. However, such a patch is unlikely to make it into any distribution of coreutils.

  • Thanks but I am not trying to do that. I just want to use something like "cat -n" but not sure what the command is to just number paragraphs instead of every line. – Leo Rogers Jan 27 '17 at 17:50

If you check the man page, you will see that you can number non-blank lines, but I don't see any options for paragraphs. You will probably need a perl script that increments a variable every time the input line is ^$.

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