Help with extracting words from fixed length files

I am very new to scripting and need to write a script that will extract the account number from a line that begins with HDR. For example, the file is as follows

HDR2010072600300405505100726     00300405505           
LBJ FREEWAY                                      DALLAS    
TELEGRAPH                                             751 HI
AR727612419      201007262010082520100823ABC
TELE EXGT401000300405505
DHL

I need to extract 00300405505

Any ideas?

awk '/^HDR/{print substr($NF,9)}' file
$ ruby -ane 'puts $F.last if $_[/^HDR/]' file

one more question...say the file actually looks like this...

HDR2010072600300405505100726 00300405505 customer name etc
LBJ FREEWAY DALLAS 
TELEGRAPH 751 HI
AR727612419 201007262010082520100823ABC
TELE EXGT401000300405505
DHL
HDR2010072600300405505100726 00300405505 customer name etc
LBJ FREEWAY DALLAS 
TELEGRAPH 751 HI
AR727612419 201007262010082520100823ABC
TELE EXGT401000300405505
DHL

There are multiple HDR lines and the customer name comes after the account that i need to extract?

Thanks

Please use

 tags when you post code or data sample !
awk '/^HDR/{print substr($(NF-1),9)}' file
$ ruby -ane 'puts $F[1] if $_[/^HDR/]' file

@Danmero:
i think substr character number start has to be 3 .

input contains:

HDR2010072600300405505100726 00300405505 

last field NF is: 00300405505
start from 3
code & output is:

awk '/^HDR/{print substr($NF,3)}' file
300405505

If it is 9 , output will be

505

Hmm, I took a long shot. This should work.

awk '{print $2}' file

If all account numbers consist of only numbers (no letters) and are 11 digits long and there are no other numbers that are 11 digits long...

grep -E -o -w [0-9]{11} file
 
grep 'HDR' file |cut -f2 -d' ' 
 
or
 
grep 'HDR' file |awk -F' ' '{print $2}'