可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Im trying to do a full back up and copy over all files from one directory into another directory
#!/bin/bash #getting files from this directory PROJECTDIRECTORY=/../../Project3 #Copied to this directory FILEBACKUPLOCATION= /../.../FMonday for FILENAME in $PROJECTDIRECTORY/* do cp $FILENAME $FILEBACKUPLOCATION done
But I keep getting this error
./fullbackup: line 6: /../../FMonday: Is a directory cp: missing destination file operand after
回答1:
I think this is what you need is FILEBACKUPLOCATION=/FMonday/
回答2:
Variable assignments in bash scripts require no space between the variable name and value or (unless quoted) within the value. Since a space was present in the line FILEBACKUPLOCATION= /../.../FMonday
, it attempted to execute /../.../FMonday
as a command (which caused the first error) with FILEBACKUPLOCATION
assigned to an empty string. The variable was then not assigned when the other command further down tried to use it (accounting for the second error).
回答3:
In my case, I just used used space and dot operator after the file name. It worked perfectly.
For Example, darthVader is a file name which is inside F drive. So, I used the command "mv /f/darthVader . "