What is the command to: Modify the "cat" command to automatically number paragraphs. These are separated by a single blank line.
Asked
Active
Viewed 104 times
0
-
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. http://unix.stackexchange.com/questions/265779/how-to-number-paragraphs – George Vasiliou Jan 27 '17 at 21:16
2 Answers
0
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.
DopeGhoti
- 73,792
- 8
- 97
- 133
-
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
0
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 ^$.
hymie
- 1,700
- 9
- 16
-
Perl script here: http://unix.stackexchange.com/questions/265779/how-to-number-paragraphs – George Vasiliou Jan 27 '17 at 21:16