I have filenames that follow a pattern like: someletters_12345_moreletters.ext
I want to extract just the 5-digit number (in this case, 12345) and store it in a variable using a Bash substring method or any other shell-compatible approach.
The format is consistent: random characters, then an underscore, a 5-digit number, another underscore, and more characters. I’m curious about the different ways this can be done—using tools like bash string manipulation, grep, sed, or awk.
What are some reliable and efficient methods for extracting that number?