echo ${text##*/}

Here, what is the meaning of 2nd line in the above 2 line script?


This is Parameter substitution and/or expansion. From the link:


Remove from $var the shortest part of $Pattern that matches the front end of $var.


Remove from $var the longest part of $Pattern that matches the front end of $var.

So ${text##*/} remove from text everything before the last /. It's useful to get the basename of directories for instance.

(There is also ${var%Pattern}/${var%%Pattern} to remove pattern that matches the back end of $var)

Not the answer you're looking for? Browse other questions tagged or ask your own question.