Bash Pipe Handling

后端 未结 3 498
再見小時候
再見小時候 2020-12-13 04:12

Does anyone know how bash handles sending data through pipes?

cat file.txt | tail -20

Does this command print all the contents of file.txt

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 04:47

    cat will just print the data to standard out, which happens to be redirected to the standard in of tail. This can be seen in the man page of bash.

    In other words, there is no pausing going on, tail is just reading from standard in and cat is just writing to standard out.

提交回复
热议问题