Skip to main content
Tweeted twitter.com/#!/StackUnix/status/162723727790977024
edited body; edited tags; edited title
Source Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k

Is the Are Linux terminalutilities smart when running piped commands?

I was just running a few commands onin a terminal and I started wondering, does Unix/Linux take shortcuts when running piped commands?

For example, let's say I have a file with one million lines, the first 10 of which contain hello world. If you run the command grep "hello world" file | head does the first command stop as soon as it finds 10 lines, or does it continue to search the entire file first?

Is the Linux terminal smart when running piped commands?

I was just running a few commands on a terminal and I started wondering, does Unix/Linux take shortcuts when running piped commands?

For example, let's say I have a file with one million lines, the first 10 of which contain hello world. If you run the command grep "hello world" file | head does the first command stop as soon as it finds 10 lines, or does it continue to search the entire file first?

Are Linux utilities smart when running piped commands?

I was just running a few commands in a terminal and I started wondering, does Unix/Linux take shortcuts when running piped commands?

For example, let's say I have a file with one million lines, the first 10 of which contain hello world. If you run the command grep "hello world" file | head does the first command stop as soon as it finds 10 lines, or does it continue to search the entire file first?

Source Link

Is the Linux terminal smart when running piped commands?

I was just running a few commands on a terminal and I started wondering, does Unix/Linux take shortcuts when running piped commands?

For example, let's say I have a file with one million lines, the first 10 of which contain hello world. If you run the command grep "hello world" file | head does the first command stop as soon as it finds 10 lines, or does it continue to search the entire file first?