0

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

ATEF CHAREF
  • 387
  • 5
  • 8
  • 18

1 Answers1

0

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'
Alfe
  • 56,346
  • 20
  • 107
  • 159