Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

What's the difference between using > and >>?

How can I use both < and > (redirection operators) in a single command?

share|improve this question
Please can you break this into separate questions. – BinaryMisfit Sep 3 '10 at 14:51
Smells like homework.... – Nifle Sep 3 '10 at 14:55
Nah, I was just reading 'Learning the shell' and I was just wondering about a few things. I'm assuming `` is command redirection, {} is for lists, and "" is to help bash understand the command. I'm a little confused on the whole echo thing though. I'm assuming I'd just say FIRST=name etc and then just echo Last, middle, ssn etc I just want a better understanding. – Tallow Sep 3 '10 at 15:06
I suggest you follow Diago's advice. This site works best when there is a single question that can be answered. So go ahead and ask four different questions, it's not like we charge extra... – Nifle Sep 3 '10 at 15:15
Thanks for doing as we asked. – Nifle Sep 3 '10 at 15:38

> redirects data from stdout (read standard out) to a file.

ls -a > my-files.txt

will take the output of ls -a and put it into a file named my-files.txt deleting/overwriting the file if it exists. Using >> instead of > in the example above will not overwrite the file if it exists but add the output of ls -a to the end of my-files.txt

< on the other hand sends data to a programs stdin (read standard in). If I have a file called my-files.txtand I want to know how many words it contains I can send it to a program called wc. This program accepts data on it's stdin so to the data to it I do

wc -w < my-files.txt

And lastly If I want to save the output of that command to a new file I can use both like so

wc -w < my-files.txt > wordcount.txt

share|improve this answer

Advanced Bash-Scripting Guide
An in-depth exploration of the art of shell scripting

  1. Special Characters, Quoting
  2. IO Redirection
  3. Introduction to Variables and Parameters
share|improve this answer

>> means just append / create if not exists, very useful for logs.

<< also exists and useful. Try:

$ cat > a <<EOF
some text here
more text

$ cat a

You see that file a contains text between two EOF.

share|improve this answer

Your Answer


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.