Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

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.

share|improve this answer

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

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.