On linux at least, and I think windows/dos shell too you can use > to "pipe" output into a file. Something like:
cat myfile.txt > mightAsWellCP.txtWhat is that piece of syntax sugar called? This is a "pipe": | so what do we call the > and < (and << and >> while were at it.)
4 Answers
I usually refer to all four variations (< << > >>) as a "redirect" when speaking to folks that I know will understand.
> is used to redirect output.
$ echo "hello" > file.txt< is used to redirect input.
$ cat < file.txtOutput:
hello>> is used to append output to the end of the file.
$ echo "world!" >> file.txtOutput:
hello
world!<< (called "here document") is a file literal or input stream literal.
$ cat << EOF >> file.txtOutput:
>Here you can type whatever you want and it can be multi-line. It ends when you type EOF. (We used EOF in our example but you can use something else instead.)
> linux
> is
> EOFOutput:
hello
world!
linux
is<<< (called "here string") is the same as <<but takes only one "word" (i.e., string).
$ cat <<< great! >> file.txtOutput:
hello
world!
linux
is
great!Note that we could have used $ cat <<< great! | tee file.txt instead of $ cat <<< great! >> file.txt, but that would do something different.
They're symbols for redirection of input/output.
Quick runthrough on the differences between the redirection syntax commands
When speaking a command-line, I usually pronounce the symbols by their function.
>"output to">>"append to"<"input from"|"pipe"
So when reading your example out loud:
cat myfile.txt > mightAsWellCP.txtI would pronounce as "cat myfile dot T X T output to might as well C P dot T X T".