# [Zsh] + coreutils, <sup><s>406</s></sup> 382 bytes <!-- language-all: lang-sh --> g(){echo She$d the $1 to catch the $2,>>o;tac o} set bird spider \ swallow iggled\ <<Z ${b=There was an old lady who${d=$3ed} a }fly.${5= I don't know why she$d that fly, Perhaps she'll die. $b}$2, That wr$4and $4and j$4inside her. `g $2 fly`$5$1, How absurd${6= to$3 a }$1. `g $@`$5cat, Imagine that$6cat. `g cat $1`$5dog, What a hog$6dog. `g dog cat`$5horse, She died of course. [Try it online!][TIO-kjwvml9j] [Zsh]: https://www.zsh.org/ [TIO-kjwvml9j]: https://tio.run/##5VTBSsNAEL3vV8xhQIW0UKu92BaPehMUhOLBbWaTTU2zJZsSasy319lstK226EkUL2GZeTvz3svsPFu9DgnweP5UqPkCOnQiQlmMo@FwIu60yhWU0oLMwKQEqaQVlNqALWWamlIRSIjSVVdcA5nsqICnzJSMWIHVagtVaFk4YCBuVK7lwrr8UZoCJaorvtnILhJSecBoLlbmSRynLp4RbB1n7TnJLKOBC3fF7Qcuqi0FhQEWG@om1tD7CR3TJKdAXHEDObXLnByNNt9m91F28V3Cb378MnnckhvNZZxkylfc0cfpffJCj9vw9S79YR/IxIG4d5UkaBPvusDJfS6Qx23YNmb@B7e0ya3yrPgagYkgNEuOdcVEVOv4@KRSId9hAHq62NuliqfBeGwuChmCqYVVhRffqnp4N98viAcQbsVhNR0dJIgVjbCvqGZ@tVtzWJ2P9rqBX7qA05oJvu0uPHO7yn9neLa9rB5jVuIKPeI59rb3BFaDEUvGvqODPQ@9ZNinF4eD5pVx3g0K9hjzYRpx0EwgI9zIMYohh3/BeiLqF0qiCCLorF8B "Zsh – Try It Online" Tricks: - the `g` function appends the line to the file `o` and then prints `o` in reverse line order, to avoid having to repeat doing it every time - `set bird ...` assigns the words to `$1`, `$2`, etc. - `\ swallow` includes a space at the start of without needing to use quotes - `<<Z` starts a heredoc which is effectively a long interpolated string - `${b=There...}` is a shorthand form assigning `b` to that string and substituting its value in - Indexed variables like `$1`, `$2`, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called `5dog`, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it - `g $@`: since we set `$1` and `$2` to `bird` and `spider` respectively, we can pass all the numbered variables to `g` in one go with `$@` instead of `g $1 $2` (it ignores the extra ones, `$3` etc.)