On Wed, May 16, 2001 at 01:30:03PM -0500, Timothy Wilson wrote:
> wilsont at galileo:~/tmp$ cat file1 >> cat file2 >> cat file3 > newfile
> wilsont at galileo:~/tmp$ cat newfile
> A
> B
> C
> wilsont at galileo:~/tmp$ 
> 
> This is exactly what I want, but the redirection on the command line doesn't
> make sense to me. In fact, the order seems exactly opposite from what it
> seems like it should be.

The shell treats this as equivalent to

cat file1 file2 file3 > newfile

because you can have output redirection anywhere in the command line and the
last redirection wins.  So, for example,

  cat file1 >> cat file2

is the same as

  cat file1 file2 >> cat

except you put the redirection in the middle of the command line rather than
at the end where it usually goes.

In your example you have three output redirections, two to append to a file
named "cat", and the last one to write to "newfile"--that last one wins, so you
could just as well drop the first two.  That's why the file "cat" gets nothing.

Your example would make anyone who know anything about the shell cringe--
you redirect to a FILE not another command.  You were probably thinking
of pipes that send the output to another command.  Read a good book on the
shell and this will all get cleared up.

-- Al