extract string portion using sed

Hi All

I have 3 files as listed below and highlighted in bold the portions of the filenames I need to extract:
TOS_TABIN218_20090323.200903231830
TOS_TABIN219_1_20090323.200903231830
TOS_TABIN219_2_20090323.200903231830

I tried
source_tabin_name=`echo $fname | sed 's/_[0-9].*[0-9]//'`

but I only get
TOS_TABIN218
TOS_TABIN219
TOS_TABIN219

The TOS TABIN218 is correct but both Tabin219 are missing the _1 and _2 respectively.
.. any how to get the extra _1 and _2

Thanks in advance

Satnam

if you have Python

# python -c "for line in open('file'):print line[:line.index('_2009')]"
TOS_TABIN218
TOS_TABIN219_1
TOS_TABIN219_2

awk

# awk '{gsub(/_2009.*/,"")}1' file
TOS_TABIN218
TOS_TABIN219_1
TOS_TABIN219_2

sed 's/_[0-9][0-9]*[.][0-9][0-9]*$//' myFile

WIkid!... works a treat. should have mentioned I was using bash v 3.x. used the last suggetsion

's/_[0-9][0-9]*[.][0-9][0-9]*$//'

Cheers

Sat

Another one with sed:

sed 's/\(.*\)_.*/\1/' file

hi man i think this will help u
TOS_TABIN218_20090323.200903231830
TOS_TABIN219_1_20090323.200903231830
TOS_TABIN219_2_20090323.200903231830

x=TOS_TABIN218_20090323.200903231830
xx=TABIN219_2_20090323.200903231830

echo ${x%*}
TOS_TABIN218
echo ${xx%
*}
TABIN219_2

or
sed 's/_2009.*//' file

Don't use external commands to manipulate strings.

source_tabin_name=${fname%_*}