0

How do I pipe the output of one command to another in unix? For example, If I want to pipe the output of sort to tail, how would I do that?

migrated from serverfault.com Feb 13 '13 at 2:05

This question came from our site for system and network administrators.

  • downvoted because this seems to show very minimal research. – strugee Jan 14 '14 at 7:14
3

The | character is used to pipe the stdout of one program to the stdin of another.

sort file.txt | tail

This will work in any POSIX compliant shell.

3

Try doing this :

sort file.txt | tail

See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html and search 2.9.2 Pipelines paragraph

  • Just that in this case sort has to finish doing its job before tail starts its. The idea is that the second in line gets to start working as soon as the first one gives it something to ork on. – vonbrand Feb 13 '13 at 3:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy