Skip to content
The Bash Insectarium

/static/insetario/en/inseto/param-prefixo/

Menu

BSH-009 · Parameters

${var#prefixo}

It gnaws at the start of the value: # takes the smallest bite, ## the largest.

The hash after the name cuts from the start of the value whatever matches the pattern: # removes the shortest match, ## the longest. The pattern uses glob wildcards, not regular expressions.

The celebrated use is ${caminho##*/}: it eats everything up to the last slash and the file name remains — a basename with no new process.

$ caminho=/var/log/colmeia/acesso.log
$ echo ${caminho#*/}
var/log/colmeia/acesso.log
$ echo ${caminho##*/}
acesso.log
The same pattern, short bite and long bite.