Code:
file="a.com/stuff/hello.mp3"
fileshort=${file##*/}
echo $file "=>" $fileshort
${VARIABLE##*/}
VARIABLE - variable to cut text from
## - ignore stuff matching the pattern, starting from the left (single # would be non-greedy, ## is greedy and it tries to match as much as it can, there are also % and %% that do similar thing at the end of the string)
*/ - pattern to throw away - in this case any sequence ended with /
#*/ a/b/c
##*/ a/b/c
%/* a/b/c
%%/* a/b/c
bolded is the returned value, the rest of the string is thrown away
Bookmarks