2013-06-21 42 views
2

我正在制作一个bash脚本,该脚本会自动将Google Chrome下载并安装到运行OSX 10.7的MacBook Pro上的用户应用程序文件夹中。我能够成功下载并挂载Google服务器上的.dmg文件,但我无法从挂载的dmg中获取实际的Google Chrome.app文件。以下是我已经写了:如何使用unix终端将安装的dmg文件复制到其他位置?

#Download and Install Google Chrome browser 

DMG='/mactest/googlechrome.dmg' 
USER="Mac" 

curl https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg > $DMG 

hdiutil attach $DMG 

cp -r '/Volumes/Google Chrome/*' '/Users/$USER/Applications' 

hdiutil unmount '/Volumes/Google Chrome' 
rm $DMG 

在按预期投放,除了这个错误这个脚本一切运行:

cp: /Volumes/Google Chrome/*: No such file or directory 

什么想法?

+0

使用双引号“而不是单个”,因此shell将为您扩展* – Joe

回答

2

您的错误是因为该文件夹中没有名为*的文件。单引号阻止shell评估*以找到匹配的文件名。尝试其中的一种:

cp -r '/Volumes/Google Chrome/Google Chrome.app' /Users/$USER/Applications 

cp -r /Volumes/Google\ Chrome/Google\ Chrome.app /Users/$USER/Applications 
相关问题