determine a compressed file type by sed 

>I'm trying hard to write a shell script to determine a compressed file
>type.
>
>Ex.
>
>cft, stands for "compressed file type"
>
>cft xxx.tar.gz will give .gz
>cft xxx.tar.Z will give .Z

But your example suggests the first most strongly to me, so:

for f; do echo ".${f##*.}"; done

is a near miss for ksh/bash (it doesn't correctly handle the case of no "." in the name). A more accurate version, which works for any Bourneish shell, is:

for f; do expr "$f" : '.*\(\..*\)'; done
>I know I can do it easily with perl but I hope a simple solution by sed
>will do. Thanks for your help!

If you really want sed:

for f; do echo "$f" | sed 's/.*\././'; done

Ken Pizzini