2017-03-17 57 views
1

我需要运行bash脚本以将文件列表复制到我的手机。如何在BASH的路径中正确调用其路径中的目录变量

这是一个试运行是工作:

cp f.jpg /home/ariela/phone/Internal\ storage/Pictures/Test 

我希望目录是一个变量。所以,我想这一点:

DEST="/home/ariela/phone/Internal\ storage/Pictures/Test" 
cp f.jpg $DEST 

,并没有工作,因为它认识到存储/图片/测试作为第二个参数,而不是路径的一部分。

我在做什么错?

回答

1

引号内没有必要躲避空间,但一定要引用它cp命令

您可以使用:

phonedir='/home/ariela/phone/Internal storage/Pictures/Test' 

cp f.jpg "$phonedir"