Is there any easy solution how to trim suffix in my filename? Problem is, that my suffix length is vary. Only the same string in filename is _L001.
See the example:
NAME-code_code2_L001_sufix
NAME-code_L001_sufix_sufix2_sufix3
NAME-code_code2_code3_L001_sufix_sufix2_sufix3
I need to output everything before _L001:
NAME-code_code2
NAME-code
NAME-code_code2_code3
I was thinking do something like this (when suffix is fixed length):
echo NAME-code_code2_L001_sufix | rev | cut -c 12- | rev
But of course my suffix length is vary. Is there any bash or awk solution?
Thank you.