Home > Mobile >  How to pass a list of paths from a variable to an options of GUN updatedb
How to pass a list of paths from a variable to an options of GUN updatedb

Time:11-10

I want to update the locatedb in a shell script via GNU updatedb on macOS.

The final command invocation looks like this:

updatedb --localpaths='/' --prunepaths='/System /Volumes/MyFirstVol /Volumes/MySecondOne /Volumes/NumeroThree'

However the volumes /Volumes/MyFirstVol, /Volumes/MySecondOne and /Volumes/NumeroThree I have space-separated in a shell $PRUNEVOLS variable:

$ echo $PRUNEVOLS
/Volumes/MyFirstVol /Volumes/MySecondOne /Volumes/NumeroThree

(Side note: I use the line

PRUNEVOLS=$(echo $(ls -1d /Volumes/* | grep -v /Volumes/IndexMe))

to initialise $PRUNEVOLS.)

My question is: How can I use $PRUNEVOLS in the updatedb invocation?


I tried various invocations in my shell scrpt::

  • updatedb --localpaths='/' --prunepaths='/System $PRUNEVOLS' - This doesn't work because $PRUNEVOLS is not expandd

  • updatedb --localpaths='/' "--prunepaths='/System $PRUNEVOLS'" - Here $PRUNEVOLS is expanded, but it still doesn't work.

CodePudding user response:

From the very first example (not using a variable), we can see that --prunepaths does not want single quotes in its argument. Therefore, a

updatedb --localpaths=/ "--prunepaths=/System $PRUNEVOLS" -

should work.

  • Related