head - Why does bash behave different by only changing the row how the parsers are called? -
i've stumbled interesting point in command on bash , can't imagine why difference happened. , sorry, did not perform search on google, archives , on - because i've no thought search for...
here test info problem: http://nopaste.info/fdec0d967d_nl.html here 2 prompts , different output - intending see begin , end of illustration data:
2014/10/09 14:49:01 hilgenbf ~/working_files/_temp$ cat test.txt | ( head -n 10; tail -n 10 ) started @ : samstag, 4. oktober 2014, 23:22:43 started @ : donnerstag, 2. oktober 2014, 15:18:29 started @ : samstag, 27. september 2014, 23:22:38 started @ : montag, 22. september 2014, 21:00:58 started @ : samstag, 4. oktober 2014, 09:03:38 started @ : samstag, 27. september 2014, 11:28:32 started @ : samstag, 20. september 2014, 10:31:31 started @ : samstag, 13. september 2014, 10:33:12 started @ : samstag, 6. september 2014, 10:03:59 started @ : montag, 1. september 2014, 09:01:33 started @ : samstag, 13. september 2014, 23:23:16 started @ : samstag, 4. oktober 2014, 23:22:42 started @ : dienstag, 30. september 2014, 18:45:10 started @ : samstag, 27. september 2014, 23:22:38 started @ : samstag, 20. september 2014, 23:30:08 started @ : samstag, 4. oktober 2014, 23:22:42 started @ : mittwoch, 1. oktober 2014, 10:09:00 started @ : samstag, 27. september 2014, 23:22:38 started @ : sonntag, 21. september 2014, 10:26:58 started @ : montag, 22. september 2014, 09:10:42 2014/10/09 14:49:05 hilgenbf ~/working_files/_temp$ cat test.txt | ( tail -n 10; head -n 10 ) started @ : samstag, 13. september 2014, 23:23:16 started @ : samstag, 4. oktober 2014, 23:22:42 started @ : dienstag, 30. september 2014, 18:45:10 started @ : samstag, 27. september 2014, 23:22:38 started @ : samstag, 20. september 2014, 23:30:08 started @ : samstag, 4. oktober 2014, 23:22:42 started @ : mittwoch, 1. oktober 2014, 10:09:00 started @ : samstag, 27. september 2014, 23:22:38 started @ : sonntag, 21. september 2014, 10:26:58 started @ : montag, 22. september 2014, 09:10:42
i know utilize first working example, curious how bash works :)
thanks all! florian
tail -n 10
doesn't consume lastly 10 lines of input; consumes all of in order find lastly 10 lines are. thus, in sec example, there nil left head
command read.
in first example, head
doesn't need read whole input, because can stop reading has read plenty output first 10 lines. however, there no guarantee head
reads only outputs. example, head -c 5
output first 5 characters, may need read @ to the lowest degree 1 total line of more 5 characters find them.
bash head tail
No comments:
Post a Comment