Extract string from filename

Hi

I need to extract the string from file name
filename: FILENAME_STRUT_01032013_XXXXXXX.TXT

I want 01032013 from the above file name. number of characters may differ before the required string but underscores(-) are same number i.e. after second underscore.

Please advise on this.

Thanks

Pls check the forum before posting any basic questions here please.

echo "FILENAME_STRUT_01032013_XXXXXXX.TXT" | cut -d"_" -f3

With awk

echo "FILENAME_STRUT_01032013_XXXXXXX.TXT" | awk -F_ '{print $3}'
01032013

Use code tags