Need help in extracting the substring in UNIX

Hi all,

I need to extract the "abcdef" from the below string Digital_abcdef_20130103.txt.gz

The length of the "abcdef" will be changing but it will be always after the word Digital_ and before the second underscore

help in this regard is highly appreciated

Pls read forum rules carefully and use code tags as advised!
You don't mention your system (HW/OS), you don't specify where and how your string comes from - based on wild guessing, try:

$ echo Digital_abcdef_20130103.txt.gz|sed 's:^Digital_\(.*\)_.*$:\1:'
abcdef
1 Like
 awk -F_ '/Digital/ {print $2}' infile

This sets filed separator to underscore _ and if Digital is found, print second field $2

var=Digital_abcdef_20130103.txt.gz
var2=${var#*_}
echo "${var2%%_*}"