4

Script:

text="//ABC/REC/TLC/SC-prod/1f9/20/00000000957481f9-08d035805a5c94bf"

echo ${text##*/}

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

fredtantini
  • 4,153
  • 1
  • 14
  • 21
Pranjalee
  • 43
  • 1
  • 1
  • 3

1 Answers1

11

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

${var#Pattern}

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

${var##Pattern}

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)

fredtantini
  • 4,153
  • 1
  • 14
  • 21