I run this in bash:

sudo ./my_script.sh arg1 >& result.log

And I'm getting this:

-bash: result.log: Permission denied

if result.log doesn't exist. However, I don't want it to exist before I run a script and want it to be created. How can I fix that?

1 Answer 1


You don't have the correct permissions to write a new file in the directory where result.log should be created. If it's already been created, you likely have permissions on that specific file to be able to write to it.

Change the permissions on that directory so that you are able to write in the directory.

  • why? it's sudo and I'm able to crate a new file
    – Ko32mo
    Jun 15, 2017 at 5:45
  • This post explains it well: stackoverflow.com/questions/82256/… Essentially, when you use sudo, any output redirection is performed as your own user, not as root.
    – Ricky
    Jun 15, 2017 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.