How to convert a DVI file to SVG on the command line

If you want to convert my.dvi to my.svg, use this command

dvi2ps my.dvi | ps2eps - > my.eps && eps2svg my.eps

This produces my.svg – note that if my.svg already exists, eps2svg will create my_1.svg, my_2.svg and so on and will not overwrite my.svg!

You can also use this shell function:

function dviToSVG { dvi2ps "$1" | ps2eps - > "${1%.*}.eps" && eps2svg "${1%.*}.eps" "${1%.*}.svg" ; }

Usage example:

dviToSVG my.dvi # Produces my.svg