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.

3
  • 1
    If you add an exit after the print statement in your awk script then it won't have to read the rest of file1.txt discarding every line and so it'd be much more efficient. Commented Mar 22, 2024 at 8:40
  • tr "\n" "," changes it's input into something that is no longer a valid test file per POSIX (no terminating newline) so YMMV regarding what sed or any other text-processing tool does with it as that's then undefined behavior. You'll probably be OK with GNU sed, idk about others. Commented Mar 22, 2024 at 8:41
  • Using paste -s -d , - in place of the tr command would solve the issue that @EdMorton points out (and also makes your sed call at the end superfluous). I have not looked at the rest of your code though. Commented Mar 22, 2024 at 9:23