[Asus Transformer TF700] elfaure:
Like a filtered shotgun method?

Credit for this method goes to [MENTION=5234163]shardsx[/MENTION] for his "shotgun" mount all cache to tmpfs script. I took that, modified it a bit, and here we have "sniper" method, almost.

Help! Ok gents, I gave it my best shot but can't seem to get to the bottom of it. Initially I had BROWSER_LIST as a variable and the first item in the list loaded to tmpfs but nothing after that. I realized it had to be an array from a simple test script I ran in parallel, changed it from a variable to an array, and now its got all kinds of problems. It is close, but no cigar. I need a little help at this point. Feel free to jump in and tell me what's wrong with this:

[Edit] I am not sure how all those * (hidden characters) got in there but that's clearly a problem, maybe the problem. They acted like tabs when I deleted them below but I didn't use any tabs. After pasting, it looks nothing like it does in my text editor. I use ES note editor and it happened on my first script too but not nearly this bad. Any suggestions how to avoid this in the future (use another editor? or how do those get there in the first place?). For indents I am using spaces not tabs so this is a bit baffeling to say the least. All I can figure is they are CR's from the original line transitions that got garbled all around after a few cut-n-pastes.

#!/system/bin/sh

#Add browser app list below
BROWSER_LIST=( com.android.browser com.dolphin.browser com.mx.browser )
#com.android.chrome
#********************************************************************************************************

for CACHE_FULL_PATH in $(find /data/data/ | grep '.*/cache$')
do
* CACHE_NAME=${CACHE_FULL_PATH/'/data/data/'/''}
CACHE_NAME=${CACHE_NAME/'/'/'_'}
* *for OBJ in "${BROWSER_LIST[@]}"
* *do
*#if [ "/data/data/${BROWSER_LIST[@]}/cache" = "$CACHE_FULL_PATH" ]
*if [ "$CACHE_FULL_PATH" = "/data/data/${BROWSER_LIST[@]}/cache" ]
*then
* * * * #for OBJ in "${BROWSER_LIST[@]}"
* * * * #do
* * umount $CACHE_FULL_PATH #2>&-
* * #rm -r ${CACHE_NAME}/* #2>&-
* * * * * rm -rf $CACHE_NAME/* #2>&-
* * mount -t tmpfs -o size=50m $CACHE_NAME $CACHE_FULL_PATH
* * * * #done * *
* fi
* done
done

# RESET VARIABLES / ARRAYS TO NIL ***************************************************************************
unset {BROWSER_LIST[@]}
unset CACHE_FULL_PATH
unset CACHE_NAME

Cleaned up so you can at least follow it below

#!/system/bin/sh

#Add browser app list below
BROWSER_LIST=( com.android.browser com.dolphin.browser com.mx.browser )
#com.android.chrome
#********************************************************************************************************

for CACHE_FULL_PATH in $(find /data/data/ | grep '.*/cache$')
do
CACHE_NAME=${CACHE_FULL_PATH/'/data/data/'/''}
CACHE_NAME=${CACHE_NAME/'/'/'_'}
for OBJ in "${BROWSER_LIST[@]}"
do
#if [ "/data/data/${BROWSER_LIST[@]}/cache" = "$CACHE_FULL_PATH" ]
if [ "$CACHE_FULL_PATH" = "/data/data/${BROWSER_LIST[@]}/cache" ]
then
#for OBJ in "${BROWSER_LIST[@]}"
#do
umount $CACHE_FULL_PATH #2>&-
#rm -r ${CACHE_NAME}/* #2>&-
rm -rf $CACHE_NAME/* #2>&-
mount -t tmpfs -o size=50m $CACHE_NAME $CACHE_FULL_PATH
#done
fi
done
done

# RESET VARIABLES / ARRAYS TO NIL ***************************************************************************
unset {BROWSER_LIST[@]}
unset CACHE_FULL_PATH
unset CACHE_NAME

[Edit] Just made a new script from the second code block with all the floating "*"'s removed and it makes no difference when you run it. Still have the same errors??

So my intent is to make a BROWSER_LIST array that the grep line is compared against then only mount the matches into tmpfs.