What does ##* means

Hi
In one of the thread I have found
echo ${SHELL##*/}

Can any of u pls let me know, what is the
interpretation for ##* over here?

Thanks.

Hey, that's mine! :stuck_out_tongue:

The Korn and Bourne Again shells (ksh and bash) have builtin mechanisms for filtering your data from a variable.

The following is taken directly from the book "Learning the Korn Shell" (ISBN 1-56592-054-6):

Assume that the variable path has the value /home/billr/mem/long.file.name, then:
Expression               Result
${path##/*/}                              long.file.name
${path#/*/}                     billr/mem/long.file.name
$path                     /home/billr/mem/long.file.name
${path%.*}                /home/billr/mem/long.file
${path%%.*}               /home/billr/mem/long

Keep in mind that this doesn't match regular expressions; the ".*" really matches a "." and then more, not just any character.

It's good for speed, instead of calling basename $path, or saying something like echo $path | sed 's/.*\///g'.
Try using time to figure out how much faster it is to do it that way...

Hope this helps.

Thanks