Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been using pipes and redirects for a long time and just realized that I don't know exactly how they are different. I just know that if you want to store the output in a file, then you use >. Otherwise most of the time you just use |. Can someone explain the difference between pipes and redirects?

share|improve this question
    
possible duplicate of Is backwards redirection the same as a pipe? –  Wuffers May 5 '11 at 3:37

1 Answer 1

up vote 9 down vote accepted

The both do the same basic thing; they redirect a file descriptor of the process executed. The difference lies in how. A pipe connects the stdout of one process to the stdin of another, whereas redirection redirects from/to a file (> from stdout to a file, < from a file to stdin).

share|improve this answer
    
The distinction sort of blurs in Linux and other systems that have /dev/fd. For example, if you run echo foo > >(somecommand), it will expand to echo foo > /dev/fd/3. It's still redirection, but to a process. –  grawity Apr 30 '11 at 18:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.