部分我的bash脚本的是访问一系列的文件夹:当我收到错误bash脚本CD不起作用
#lsit of folders
locations=("/Volumes/Israel\ Hernandez/Quantitative\ Data/Microglia\ data/3\ month/Mutant/314a"
"/Volumes/Israel\ Hernandez/Quantitative\ Data/Microglia\ data/3\ month/Mutant/314b"
"/Volumes/Israel\ Hernandez/Quantitative\ Data/Microglia\ data/3\ month/Mutant/314c")
for i in "${locations[@]}"
do (
#change to directory
cd "$i"
#convert tiff to png
但是:
/Users/luna/Documents/Ethan/scripts/microglia.sh: line 16: cd: /Volumes/Israel\ Hernandez/Quantitative\ Data/Microglia\ data/3\ month/Mutant/314a/: No such file or directory
我一直在努力,只是CD进入该终端上的文件夹,它绝对有效。它怎么会不会在shell脚本中工作?
这是一个想法。你应该在你的终端上试试它。这两个将工作:'CD /卷/以色列\埃尔南德斯','CD“/卷/以色列埃尔南德斯”'。但是这个不起作用:'cd'/ Volumes/Israel \ Hernandez''。将目录分配到数组位置中的双引号内的反斜杠是罪魁祸首。 – alvits