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*

4
  • Thanks for your answers! If I understand correctly the last approach is exclusively pedagogic, as it is longer, involves splitting the script, and has the line/pattern addressing issue which is not present in the first two solutions. (Right?) Commented Dec 30, 2014 at 18:17
  • Thanks again, Don. (Sorry for the name update in the middle of this thread.) I guess your second method can become way simpler by running rm x* first and then simply for i in x*; do cat $x | tee /dev/tty; done | ed. I will probably feel most comfortable adapting Mark's answer with printf '%s\n' "$line" instead of echo "$line", removing IFS= as there's only one variable and changing sleep 0.5 to sleep 0 (noticing the many options you said I would have). I learned a lot with your feedback! Thanks! Commented Jan 1, 2015 at 22:11
  • Thanks again! Now I see why IFS= is there, even if the whole line is to be read into a single variable. Some information may be lost. Unlikely in this case, but nice to know this best practice. If I may ask, did you pick all of this up "by doing and learning", or was there a single source/book that you followed carefully and would suggest. Thanks once more! Happy 2015! Commented Jan 2, 2015 at 18:44
  • [Meta-question: for some reason my "at"+"your username" doesn't stick. Maybe because I asked the question?] I forgot about split(1). Yes, I'd be inclined to delete all files beginning with x, maybe in a temporary directory. I'm pretty sure split(1) generates file names in alphabetical order, so that cat $x* gives you back the original file. I've used it in that basic way a few times. The UNIX founders got a lot of things right! Commented Jan 2, 2015 at 19:10