Whats the difference between these
Python abcd.py > abcd.logs
and
Python abcd.py >> abcd.logs
In either case, the output of the program is stored in the file whose name is provided after the redirection operator.
Whats the difference between these
Python abcd.py > abcd.logs
and
Python abcd.py >> abcd.logs
In either case, the output of the program is stored in the file whose name is provided after the redirection operator.
It might depend on the shell you are using but the common behaviour is that
>
will overwrite the target file, while>>
will append to it. If the target file does not exist it will be created in both cases.If you use
>
:if you use
>>
:However you often can change this default behavior. And there's also
>|
which you can encounter in script files.Clobber - Option
The most common alteration to these rules are usually known as the "clobber"-option.
In bash you can achieve this with:
In Zsh you can achieve this with:
If the "clobber"-option is set (or the "noclobber"-option unset), it will work like the following:
If you use
>
with clobber-option:if you use
>>
with clobber-option:if you use
>|
with clobber-option: