I need to run the following command with sudo (technically just the dd part of this command needs sudo):

xz -d -c -v nvme0n1.dd.xz | xdelta3 -e -9 < (dd if=/dev/nvme0n1 bs=1GB) nvme0n1.dd.xdelta

Usually when I need to run something like this with multiple pipes as sudo I simply pass it as a string to:

sudo bash -c "command"

But when I do that with this command I get the following error:

bash: Syntax error near unexpected token (

I tried escaping the brackets but when I do that I get:

bash: (dd no such file or directory

What's the best approach to run this command as sudo?

  • 2
    I don't think you can have whitespace between the < and ( in a bash process substitution - regardless of the use of sudo – steeldriver Jan 11 at 23:15
  • 3
    What steeldriver just said. Also, I notice that your error messages have Bash capitalized rather than bash. This tells me you have modified the error messages. Please don't do that. We need to trust that what you show is exactly what you see. – Kusalananda Jan 11 at 23:24

As mentioned by steeldriver the issue was indeed the extra space between < and (.

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.