expansion

Bash Remove longest prefix

Removes the longest matching leading segment; no match leaves the value unchanged.

Formal Syntax & Structure

bash syntaxbash
${p##pattern}

Return Value

shell expansion result

Removes the longest matching leading segment; no match leaves the value unchanged.

Working Example

Example Snippetbash
p=a/b/cprintf '%s\n' "${p##*/}"
Bash Reference