Home > Enterprise >  Not able to copy the files in mac
Not able to copy the files in mac

Time:01-02

Not able to copy the files from one folder to another folder and keeps on getting the below error message. Trying to copy from folder /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home/lib to /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

I am giving the command like this by staying in the folder /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home/lib:

cp tool.jar /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

Error Message:

usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directo

OS: mac OS Big Sur

CodePudding user response:

The directory you're trying to copy to has a space in it, so cp "sees" arguments - "tool.jar", "/Library/Internet" and "Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib". As you can see from the error, this isn't a valid input for cp.

You can escape the destination folder by surrounding it with quotes:

cp tool.jar "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib"
# Here------^--------------------------------------------------------------------^

CodePudding user response:

You have to escape the space character in the path because space characters are parameter separators.

Either with a backslash

cp tool.jar /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

or by wrapping the path in single or double quotes

cp tool.jar '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib'
  • Related