我想通过macOS上的GNU updatedb在shell脚本中更新locatedb
。
最后的命令调用如下所示:
updatedb --localpaths='/' --prunepaths='/System /Volumes/MyFirstVol /Volumes/MySecondOne /Volumes/NumeroThree'
但是,卷/Volumes/MyFirstVol
、/Volumes/MySecondOne
和/Volumes/NumeroThree
I在shell $PRUNEVOLS变量中以空格分隔:
$ echo $PRUNEVOLS
/Volumes/MyFirstVol /Volumes/MySecondOne /Volumes/NumeroThree
(Side注:我用线
PRUNEVOLS=$(echo $(ls -1d /Volumes/* | grep -v /Volumes/IndexMe))
初始化$PRUNEVOLS。)
我的问题是:如何在updatedb调用中使用$PRUNEVOLS?
我在shell scrpt中尝试了各种调用::
updatedb --localpaths='/' --prunepaths='/System $PRUNEVOLS'
-这不起作用,因为$PRUNEVOLS未扩展updatedb --localpaths='/' "--prunepaths='/System $PRUNEVOLS'"
-这里$PRUNEVOLS被展开了,但是它仍然不工作。
1条答案
按热度按时间i34xakig1#
从第一个示例(未使用变量)中,我们可以看到
--prunepaths
不希望在其参数中使用单引号。因此,A应该可以