Artificial intelligent assistant

get string from file name using KSH I have a file name like 'XXAR_CUST_INV_pt_PT_BURST.xml'. I need only "BURST" as result. note: file name can have many "_"'s (Underscores). So, I need string from last underscore and before extension ".xml" which "BURST" s="XXAR_CUST_INV_pt_PT_BURST.xml" BUSRTING=''; source <(sed -r 's/(.*)_([^_]*)[.].*/BUSRTING="\1"/' <<< "${s}") # Result: BUSRTING=$(printf '%s' "$BUSRTING" | tr '[a-z]' '[A-Z]') echo BUSRTING=$BUSRTING" expected result is BURST s="XXAR_CUST_INV_pt_PT_BURST_US.xml" BUSRTING=''; source <(sed -r 's/(.*)_([^_]*)[.].*/BUSRTING="\1"/' <<< "${s}") # Result: BUSRTING=$(printf '%s' "$BUSRTING" | tr '[a-z]' '[A-Z]') echo BUSRTING=$BUSRTING" expected result is US

BURSTING=${s%.xml} # cut off extension
BURSTING=${BURSTING##*_} # cut off anything before the last underscore
typeset -u BURSTING # make uppercase

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3494c6b4ab9ed3ea8d090bc689b88095