My tech blog https://blog.neon.moe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
405B

  1. BEGIN {
  2. if (length(REPLACE) == 0) {
  3. REPLACE = "{{insert-here}}";
  4. }
  5. }
  6. NR == FNR {
  7. a[n++] = $0;
  8. next
  9. }
  10. LOAD_LINES && /\{\{[0-9]\}\}/ {
  11. i = match($0, /\{\{[0-9]\}\}/);
  12. line = substr($0, i + 2, 1);
  13. sub(/\{\{[0-9]\}\}/, a[line]);
  14. }
  15. {
  16. if ($0 ~ REPLACE) {
  17. for (i = 0; i < n; i++) {
  18. print a[i];
  19. }
  20. next
  21. } else {
  22. print
  23. }
  24. }