我想locatedb在 macOS 上通過 GNU updatedb 更新 shell 腳本。
最終的命令呼叫如下所示:
updatedb --localpaths='/' --prunepaths='/System /Volumes/MyFirstVol /Volumes/MySecondOne /Volumes/NumeroThree'
但是,volumes/Volumes/MyFirstVol和/Volumes/MySecondOne我/Volumes/NumeroThree在 shell $PRUNEVOLS 變數中以空格分隔:
$ echo $PRUNEVOLS
/Volumes/MyFirstVol /Volumes/MySecondOne /Volumes/NumeroThree
(旁注:我使用這條線
PRUNEVOLS=$(echo $(ls -1d /Volumes/* | grep -v /Volumes/IndexMe))
初始化 $PRUNEVOLS。)
我的問題是:如何在 updatedb 呼叫中使用 $PRUNEVOLS?
我在我的 shell 腳本中嘗試了各種呼叫::
updatedb --localpaths='/' --prunepaths='/System $PRUNEVOLS'- 這不起作用,因為 $PRUNEVOLS 沒有展開updatedb --localpaths='/' "--prunepaths='/System $PRUNEVOLS'"- 這里 $PRUNEVOLS 被擴展了,但它仍然不起作用。
uj5u.com熱心網友回復:
從第一個示例(不使用變數)中,我們可以看到--prunepaths它的引數中不需要單引號。因此,一個
updatedb --localpaths=/ "--prunepaths=/System $PRUNEVOLS" -
應該管用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/531351.html
標籤:重击壳命令行参数牛定位
上一篇:洗掉兩個雙引號后的下一個單雙引號
下一篇:bashshell的清潔環境
