How to use testfor with a mob with a two-word name?

Solution 1:

In 1.13 and above you can add quotes to the name in the selector, like so:

/kill @e[name="Grumpy Bill"]

In 1.12 and below a selector cannot test for a name with spaces or most symbols; it is marked on the bug tracker as "Won't Fix" (but is fixed in 1.13+).

You can however select them by NBT data with their "CustomName" tag. Like this:

/testfor @e {CustomName:"Grumpy Bill"}

If you want to do something other than test for them existing, you'll need to create a dummy scoreboard objective, objectiveName, and then run something like this:

/scoreboard players set @e objectiveName 1 {CustomName:"Grumpy Bill"}

And then:

/kill @e[score_objectiveName_min=1]