cat < file1 > file2
is not a UUOC. Classically, <
and >
do redirections which correspond to file descriptor duplications at the system level.
File descriptor duplications by themselves don’t do a thing (well, >
redirections open with O_TRUNC
, so to be accurate, output redirections do truncate the output file). Don’t let the <
>
symbols confuse you. Redirections don’t move data—they assign file descriptors to other file descriptors.
In this case you open file1
and assign that file descriptor to file descriptor 0
(<file1
== 0<file1
) and file2
and assign that file descriptor to file descriptor 1
(>file2
== 1>file2
).
Now that you’ve got two file descriptors, you need a process to shovel data between the two—and that’s what cat
is for.