문제

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