>
redirect the standard output (aka STDOUT
) of the current command into a file or another descriptor.
These examples write the output of the ls
command into the file file.txt
ls >file.txt
> file.txt ls
The target file is created if it doesn't exists, otherwise this file is truncated.
The default redirection descriptor is the standard output or 1
when none is specified.
This command is equivalent to the previous examples with the standard output explicitly indicated:
ls 1>file.txt
Note: the redirection is initialized by the executed shell and not by the executed command, therefore it is done before the command execution.