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*

8
  • Welcome to Unix & Linux!  Good job for a first post.  (1) While this may answer the question, it would be a better answer if you could explain how/why it does so.  The site’s standards have evolved over the past four years; while code-only answers were acceptable in 2011, we now prefer comprehensive answers that provide more explanation and context.  I’m not asking you to explain the entire script; just the parts that you changed (but if you want to explain the entire script, that’s OK too).  (BTW, I understand it fine; I’m asking on behalf of our less experienced users.)  … (Cont’d) Commented Oct 10, 2015 at 6:18
  • (Cont’d) …  Please do not respond in comments; edit your answer to make it clearer and more complete.  (2) Fixing the script so that it does not need to hold the entire array in memory is a good improvement, but I’m not sure whether it’s appropriate to say that your version is “more efficient” when you have three unnecessary cat commands; see UUOC.  … (Cont’d) Commented Oct 10, 2015 at 6:19
  • (Cont’d) …  (3) Your code is safe, since you set FILENAME and you know what you set it to, but, in general, you should always quote shell variables unless you have a good reason not to, and you’re sure you know what you’re doing.  (4) Both your answer and Bruce’s ignore negative input (i.e., numbers beginning with -); there is nothing in the question to suggest that this is correct or desired behavior.  Don’t feel bad; it’s been over four years, and, apparently, I’m the first person who noticed. Commented Oct 10, 2015 at 6:20
  • Made edits as per suggestions. Didn,t knew about the overhead of cat command. Always used it to stream single files. Thanks for telling me about UUOC..... Commented Oct 10, 2015 at 15:40
  • Good.  I eliminated the third cat and added to the explanation. Commented Oct 10, 2015 at 17:10