Command line (Lyx > Markdown)
lyx --export latex file.lyx
pandoc --no-wrap -f latex -t markdown file.tex > file.md
Command line (Markdown > Lyx)
pandoc --no-wrap -f markdown -t latex file.md > file.tex && tex2lyx
file.tex && lyx file.lyx
(--no-wrap makes sure we don't screw up e.g. \hrefs by spanning them over multiple lines)
sudo apt-get install pandoc lyx
pandoc --no-wrap -f latex -t markdown -o $$o $$i
(might need extra whitespace at end)