سؤال

I run this command on ubuntu:

su - test -c cp /home/test/toto.txt /home/test/dir

But I have this error!

cp: missing file operand

anyone has an idea about the problem? thank you

هل كانت مفيدة؟

المحلول

Option -c is understood by command su, taking the next argument (not the remaining) to be the command. That next command is just cp.

Try putting the command into quotes:

su - test -c 'cp /home/test/toto.txt /home/test/dir'

If this is problematic because you want to have quotes inside the command, try using escape instead of the inner quotes:

su - test -c 'echo hello\ \ there'
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top