| 1 | #!/bin/bash |
| 2 | # poem.sh: Pretty-prints one of the ABS Guide author's favorite poems. |
| 3 | |
| 4 | # Lines of the poem (single stanza). |
| 5 | Line[1]="I do not know which to prefer," |
| 6 | Line[2]="The beauty of inflections" |
| 7 | Line[3]="Or the beauty of innuendoes," |
| 8 | Line[4]="The blackbird whistling" |
| 9 | Line[5]="Or just after." |
| 10 | # Note that quoting permits embedding whitespace. |
| 11 | |
| 12 | # Attribution. |
| 13 | Attrib[1]=" Wallace Stevens" |
| 14 | Attrib[2]="\"Thirteen Ways of Looking at a Blackbird\"" |
| 15 | # This poem is in the Public Domain (copyright expired). |
| 16 | |
| 17 | echo |
| 18 | |
| 19 | tput bold # Bold print. |
| 20 | |
| 21 | for index in 1 2 3 4 5 # Five lines. |
| 22 | do |
| 23 | printf " %s\n" "${Line[index]}" |
| 24 | done |
| 25 | |
| 26 | for index in 1 2 # Two attribution lines. |
| 27 | do |
| 28 | printf " %s\n" "${Attrib[index]}" |
| 29 | done |
| 30 | |
| 31 | tput sgr0 # Reset terminal. |
| 32 | # See 'tput' docs. |
| 33 | |
| 34 | echo |
| 35 | |
| 36 | exit 0 |
| 37 | |
| 38 | # Exercise: |
| 39 | # -------- |
| 40 | # Modify this script to pretty-print a poem from a text data file. |