Strip extention from filename

Hey,

How to strip the extention from filename?

MY_XML.xml -> MY_XML
MY\_TEST_FILE.txt -> MY\_TEST_FILE
HELLO_WORLD.xls -> HELLO_WORLD

Thanks in advance!

Say filename holds each of those names. Then this would work

${filename%\.*}

gives the filename sans the extension. If the file contains more than one . , i.e. like filename.1.2.3, then the above would give filename.1.2

If you need to remove all sub.extensions, then it would be

${filename%%\.*}

echo $filename|cut -d"." -f1