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

I'm new to Linux and trying to figure out what this statement in a Bash file does. I think it combines stdout, stderr and output it to the file $log is pointing to and append the multiline string to it. Is it right?

cat << EOF >> $log 2>&1   
the quick brown  
fox jumps  
share|improve this question
Type man bash, and read up on it. None if the stuff after cat is an input to cat, it is interpreted by bash before cat is started. On Unix much stuff is done by the shell not the commands. This makes things simpler to write and more consistent to use. – richard Aug 30 '14 at 16:11
it does the same thing every cat statement does - it concatenates stdin to stdout. – mikeserv Aug 30 '14 at 17:58
The title is undescriptive, but I can't think of a good summary either, mostly because it's unclear what exactly about the command is confusing. Maybe something like "What does a pair of less-than-signs mean in bash?" would work. – Anko Aug 30 '14 at 23:34

First, cat must be written lowercase. This command statement uses the concept of here documents.

The first part cat << EOF means that stdin (standard input) of the command comes afterwards. All that comes after the first line until the word EOF is the standard input to the command cat. Or from the documentation:

This type of redirection instructs the shell to read input from the current source until a line containing only delimiter (in your case it's EOF) (with no trailing blanks) is seen. All of the lines read up to that point are then used as the standard input for a command.

The second part of the command >> $log 2>&1 means that the output of stdout and stderr both, should be appended to a file whose name is in the variable $log.

Conclusion: A file like this is now generated:

the quick brown
fox jumps
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.