Sample Header Ad - 728x90

Restarting poem line numbering any 4 lines after a blank space

1 vote
3 answers
70 views
This is related to very interesting answer given here: https://unix.stackexchange.com/questions/680747/any-text-utility-or-hack-to-numbering-poems-lines-omitting-certain-numbers/680752#
'FNR % 4 == 0 { printf "%6i %s\n", FNR, $0 ; next }; {printf "%6s %s\n", "", $0}' poem.txt
That does the job of numbering poem lines automatically. However, in case we have several poems separated by blank lines, in this way: OF Mans First Disobedience, and the Fruit Of that Forbidden Tree, whose mortal tast Brought Death into the World, and all our woe, With loss of Eden, till one greater Man Restore us, and regain the blissful Seat, Sing Heav'nly Muse, that on the secret top Of Oreb, or of Sinai, didst inspire That Shepherd, who first taught the chosen Seed, In the Beginning how the Heav'ns and Earth Rose out of Chaos: or if Sion Hill Delight thee more, and Siloa's brook that flow'd Fast by the Oracle of God; I thence Invoke thy aid to my adventrous Song, That with no middle flight intends to soar Above th' Aonian Mount, while it pursues Things unattempted yet in Prose or Rhime. I wonder if line numbering any four lines can be restarted after a blank space, in order to have: OF Mans First Disobedience, and the Fruit Of that Forbidden Tree, whose mortal tast Brought Death into the World, and all our woe, 4 With loss of Eden, till one greater Man Restore us, and regain the blissful Seat, Sing Heav'nly Muse, that on the secret top Of Oreb, or of Sinai, didst inspire 8 That Shepherd, who first taught the chosen Seed, In the Beginning how the Heav'ns and Earth Rose out of Chaos: or if Sion Hill Delight thee more, and Siloa's brook that flow'd 4 Fast by the Oracle of God; I thence Invoke thy aid to my adventrous Song, That with no middle flight intends to soar Above th' Aonian Mount, while it pursues 8 Things unattempted yet in Prose or Rhime.
Asked by Dingo (339 rep)
Feb 4, 2022, 08:22 AM
Last activity: Feb 8, 2022, 06:16 PM