How do I kill all of just one entity with /kill? [duplicate]

I like to play Minecraft and the bats are annoying and tried doing /kill @e [type = bat] then I pressed enter and all entities were killed. It ruined my world! How do I target the all of bats and ONLY the bats without killing anything else?


Spaces aren't allowed between selectors and their arguments. It'll be killing @e and ignoring everything after the space. Try:

/kill @e[type=bat]