I have some code I'm using with Windows and SED to give me the first set of eight characters in a file name that keeps giving me the second set only that I cannot figure out what I'm doing wrong.
My Code:
echo JiggySauce_20161208_21325005_Meat.txt | sed -r "s/.*_([0-9]*)_.*/\1/g"
Addition Example (so regex per underbar delimiters won't always work):
echo JiggySauce_Mustard_Mayo_20161208_21325005_Meat.txt | sed -r "s/.*_([0-9]*)_.*/\1/g"
I keep getting this wrong result (at least not what I need):
21325005
My expected result:
20161208
I could even live with (preferrably not but could work with that I suppose):
20161208_21325005
Please help me with this if you have an answer as I'm at a standstill looking dumb and stumped over here like UHHH....