sed problem

Hi
i am stuck with a very silly problem :mad:

below is my code

echo 201010_1212_121.xml

i need to replace xml with csv so i did

 
echo 201010_1212_121.xml  | sed 's/.*\.xml/.*\.csv/'
 
echo 201010_1212_121.xml  | sed 's/*.xml/*.csv/'
 
echo 201010_1212_121.xml  | sed 's/......_...._....xml/......_...._....csv/'

But neither it is giving me correct result

please tell me where i am wrong

This one:

echo "201010_1212_121.xml"|sed -e "s/\.xml$/\.csv/"

Hi,

sed 's/xml$/csv/'

If you have that string in a shell variable, you can probably just do:

echo "${var%xml}"csv

Regards,
Alister

hi
thanks all for ur reply

but there is little twist in question

actually i don't know what would be the extension

it could be xml or it could be abcy or dfjhghdf or abcndfjdhgk

even i don't know how many character would be in extension
so besically i need to replace the extension with csv

please help me in this

A variation to Alister's suggestions should do:

sed 's/\.[^.]*$/.csv/'
echo "${var%.*}.csv"