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*

5
  • I don't think this answers what the OP is trying to do. The idea is for sequential commands to each consume a portion of the same pipe stream, each picking up exactly where the previous one left off. Commented Jul 22, 2013 at 20:29
  • What I'm trying to achieve is a bit different of your script. I would like, for example, cmd1 processing the first 10 lines, cmd2 processing the next 15 lines, and so on. Cmd1, cmd2, etc are bash functions, and these functions decide the number of lines to be processed according to the input. Commented Jul 22, 2013 at 20:42
  • @arnaldocan Ok, I think rightly understand the need, look the sample script and last command sample. Commented Jul 22, 2013 at 21:09
  • I think the fourth example solves the problem. Is there any way to avoid using "read" because of its speed limitations on large files? Commented Jul 22, 2013 at 21:12
  • You may use mapfile -n $numLines arraOfLines Commented Jul 22, 2013 at 21:46