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'd rather say that "most commands have either single or double output channel - stdout (fd 1) and very often stderr (fd 2)". Commented Aug 17, 2011 at 15:15
  • Also, could you by the way explain why you use while IFS= read -r line;? The way I see it, IFS has no effect here since you assign value to only one variable (line). See this question. Commented Aug 17, 2011 at 15:33
  • @rozcietrzewiacz I've made a mention of stderr, and see the first part of my answer for why IFS makes a difference even if you're reading a into single variable (it's to retain the leading whitespace). Commented Aug 18, 2011 at 1:26
  • Couldn't you do the same with sed -ne 'w odd.txt' -e 'n;w even.txt'? Commented Nov 23, 2017 at 0:07
  • 4
    @Wildcard You could do the same with other tools, sure. But the goal of this answer was to illustrate redirections in the shell. Commented Nov 23, 2017 at 12:12