I use below command to empty a file
> file.txt
It works perfectly fine! But there are some files with root
user permissions. So I tried
sudo > different-file.txt
and I got below verbose
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s]
[<command>]
usage: sudo -e [-AknS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file ...
This suggests that there is some syntax error in my command.
What is wrong?
sudo cp /dev/null > /to/be/truncated/file
. I dunno why exactly it spits me out abash: /to/be/truncated/file: Permission denied
but it does. Omit that damn>
and it works. D'oh. (Well, in my case, the origins may still date back to my MS-DOS times, where I would frequently useC> type (...)
plus the redirection operator>
.) – syntaxerror Jan 29 '16 at 17:27