CUT command delimiter in reverse

Hi,
I've a situation where,

 
a=xxx.yyy.zzz.txt
EXTN=`echo $a | cut -d . -f2`

Using the above code it delimites and will return "yyy.zzz.txt" to EXTN. But i need to get only the extension "txt". so as per the above code it delimits in the first "." itself. Can anyone help how to do this cut in

so that i always get the "txt" as a result.

Thanks,
Vasanth.

first, the command EXTN=`echo $a | cut -d . -f2` will return yyy

If you need get txt , thy this:

EXTN=`echo $a | cut -d . -f4`

or

EXTN=${a##*.}
 
echo $a
xxx.yyy.zzz.txt
EXTN=$(echo $a | cut -d . -f 4)
echo "$EXTN"
txt

Hi rdcwayx,

Thanks for you reply!
It works in both the way. But the 2nd one suits my situation well becuase somtime i can have only one .(dot) in my input or 2 or 3 .(dots) somtime. I'm little new... and i don't understand the below code :confused:

It would be great if you can you explain me the above code.

Thanks,
Vasanth.

It removes the greatest occurence of the pattern '*.' at the beginning of variable 'a'.
See all the parameter expansion posssibiities in : Bash Reference Manual

Also, see POSIX version Shell Command Language to see what's possible in shells other than bash

Thank You All for your guidance which was most helpful for me.
-Vasanth.