But this one means "everything(*) to the left of the first '-'":
INDEX=${OUTSTR%%-*}
And this one means "everything to the right of the first '-'":
FILENAME=${OUTSTR#*-}
You can play with it in a terminal to understand it better:
Code: Select all
TEST=59170-LazY-Fred-English-Locals.tar.gz
echo ${TEST%%-*}
echo ${TEST#*-}
Code: Select all
echo ${TEST%-*}
echo ${TEST##*-}
Anyway, a little trick like that can make your code run hundreds of times faster than some multi-command pipeline. For a single instance you'd not notice the difference, but if that line is being used inside a loop which runs many times, then the difference can be dramatic.