Deleting the file except one type of file

I need the unix command which is used to delete the file except one the of file format.

example:
In folder
a.txt
b.txt
c.prn
d.st
g.lg

Output :

except .st files remaining all are deleted from the folder.

ls -1| grep -v \.st$| xargs -I {} rm -f {}

i got the below error while give ur command

kganeshb@its04489:~/rm $ ls -1| grep -v \.st$| xargs -1 {} rm -f {}
xargs: invalid option -- 1
Usage: xargs [-0prtx] [-e[eof-str]] [-i[replace-str]] [-l[max-lines]]
[-n max-args] [-s max-chars] [-P max-procs] [--null] [--eof[=eof-str]]
[--replace[=replace-str]] [--max-lines[=max-lines]] [--interactive]
[--max-chars=max-chars] [--verbose] [--exit] [--max-procs=max-procs]
[--max-args=max-args] [--no-run-if-empty] [--version] [--help]
[command [initial-arguments]]

Try letting "-I {}" out of it. If it still doesn't work, try

man xargs

Thank it is working after i removing the -I {}

Hi Zaxxon,
I executed the following command

ls -l|grep '\.txt$'|xargs -I {} rm -f {}

but it shows error like following

rm: illegal option -- w
rm: illegal option -- -
rm: illegal option -- -
rm: illegal option -- -
rm: illegal option -- -
rm: illegal option -- -
rm: illegal option -- -
rm: illegal option -- -
rm: illegal option --
rm: illegal option --
rm: illegal option --
rm: illegal option -- 1
rm: illegal option --
rm: illegal option -- b
rm: illegal option -- a
rm: illegal option -- s
rm: illegal option -- u
rm: illegal option -- a
rm: illegal option --
rm: illegal option --
rm: illegal option --
.
.

Thanks.

You copied it incorrectly. It should be

ls -1 (as in the number one), not ls -l (letter l)

thanks a lot.