append_output.sh 306 B

12345678910111213
  1. #!/bin/bash
  2. set -e
  3. src=$(sed -n -e '/### OUTPUT ###/,$!p' "$1")
  4. output=$(python "$1" | sed 's/^/# /')
  5. # These are done separately to avoid having to insert a newline, which causes
  6. # problems when the text itself has '\n' in strings
  7. echo "$src" > $1
  8. echo -e "\n### OUTPUT ###" >> $1
  9. echo "$output" >> $1