我正在尝试复制不同文件夹中的文件。文件夹名称在运行时动态更改。所以我试图将其保存在变量中并尝试复制。它的投掷错误。请你帮我解决一下
current_path : '/tmp/build/bf45481f'
brokerutils='/resource-app/ServiceBrokers/BrokerCommonUtils/*'
broker='/resource-app/ServiceBrokers/AuthServiceBroker_New/'
path_source="$current_path$brokerutils"
path_dest="$current_path$broker"
cp -R "${path_source}${path_dest}"
Path_dest:/tmp/build/bf45481f/resource-app/ServiceBrokers/AuthServiceBroker_New/
Path_source:/tmp/build/bf45481f/resource-app/ServiceBrokers/BrokerCommonUtils/BrokerRoutes.js /tmp/build/bf45481f/resource-app/ServiceBrokers/BrokerCommonUtils/DALAdapter.js / tmp / build / bf45481f / resource-app / ServiceBrokers /BrokerCommonUtils/gistdb.js / tmp / build / bf45481f / resource-app / ServiceBrokers / BrokerCommonUtils / middleLayer
错误:cp:在'/ tmp / build / bf45481f / resource-app / ServiceBrokers / BrokerCommonUtils / * / tmp / build / bf45481f / resource-app / ServiceBrokers / AuthServiceBroker_New /'之后缺少目标文件操作数
简单示例使用shell脚本将文件从1个文件夹复制到另一个文件夹名称是动态的文件夹
!/bin/bash
echo "Enter sourc path:"
read sourc
echo "Enter dest path:"
read dest
path_source="$sourc"
path_dest="$dest"
cp -rf $path_source $path_dest
我认为没有一个错误:你错过$ {path_source}和$ {path_dest}之间的空格。尝试使用cp -R "${path_source} ${path_dest}"