Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • I'm slightly surprised that MSTRG.2 is being replaced in the final output file. You are clobbering the file in each iteration, so I'd expect that only the last replacement would be visible. Just do the redirection to output after the loop instead of in each iteration (just like you're already redirecting the loop's input from template). I'm not posting this as an answer since I'm not sure why you say (or how it's possible) that MSTRG.2 is being replaced. Commented Oct 15, 2019 at 16:04
  • Not sure I understand. How do I redirect the output after the loop is finished? Commented Oct 15, 2019 at 16:11
  • while ...; do ...; done <template >output. And redirect the two echo calls to standard error to avoid getting them in the output: echo ... >&2. Commented Oct 15, 2019 at 16:26
  • Possible duplicate of How to perform replacements defined in one file on another file Commented Oct 15, 2019 at 19:44
  • You don‘t need the read loop at all, but do it in one pass by adapting the scheme given in the linked answer. Commented Oct 15, 2019 at 19:46