You can do it like this https://mcdiamondfire.com/threads/how-do-i-make-a-practical-line-that-does-damage-like-a-magic-wand.4721/post-19425
But instead of Select Player By Name at the start, use Select All Entities and maybe you should Filter Selection -> If Entity -> Is Mob (so you don't hit...