When you attempt to modify a file without having write permissions on it, you get an error:
> touch /tmp/foo && sudo chown root /tmp/foo
> echo test > /tmp/foo
zsh: permission denied: /tmp/foo
Sudoing doesn't help, because it runs the command as root, but the shell handles redirecting stdout and opens the file as you anyway:
> sudo echo test > /tmp/foo
zsh: permission denied: /tmp/foo
Is there an easy way to redirect stdout to a file you don't have permission to write to, besides opening a shell as root and manipulating the file that way?
> sudo su
# echo test > /tmp/foo