How can doctors tell the difference between bacterial meningitis and viral meningitis?

Lumbar Puncture. Though the history can be similar- the profile on the lumbar puncture usually will aallow differentiation.
Cerebrospinal fluid. CSF analysis will distinguish between bacterial and viral causes. Also CSF cultures most probably will be positive in bacterial cultures.