For a map I'm making, there are skeletons that you have to shoot, kind of like a carnival game. But I want one to spawn only when there are none there, so they all don't pile up. Is there a way I can use
/testfor to do this?
While DominatorX's solution is perfectly valid - the command you are looking for might look something like this:
Mobtype would be replaced with the mob you are looking for, like
Skeleton will search for skellies, and
Zombie will search for zombies. Alternatively, if you don't need to specify the type of mob, you can remove the
[type=Mobtype] all together. This will just search for any entity.
**this can be used to specify a specific location, and a radius around that location. Alternatively, you can just use
r=r and it will test within the point of origin (the command block)