This is one of a number of surviving Ugaritic incantations for exorcisms:
I will recite an incantation against the suspect ones;
alone I will overpower . . . .
And may the Sons of Disease turn around,
may the Sons of Disease fly away . . . .
may they beat themselves like the ill of mind!
Go back . . .
The Legion to the Legions,
The Flies to the Flies,
those of the Flood to the Flood
From Incantations I lines 20-30 (p. 179 of An Anthology of Religious Texts from Ugarit by Johannes de Moor, 1987)
Now I don’t know the original word translated as Legions, and I do not have access to my copy of the companion cuneiform and dictionary volume of this anthology. But though I have not included the scholarly marks indicating gaps and guesses in the above, it is a scholarly translation and the Legion translation is cross referenced to Mark 5:9
And He was asking him, “What is your name?” And he said to Him, “My name is Legion; for we are many.”
It seems superfluous to compare the incantation’s order that the demons beat themselves like the ill of mind with Mark 5:5
Constantly, night and day, he was screaming among the tombs and in the mountains, and gashing himself with stones.
And to compare the demons of the flood turning back to the flood with Mark 5:13
And coming out, the unclean spirits entered the swine; and the herd rushed down the steep bank into the sea, about two thousand of them; and they were drowned in the sea.
The same text notes that Baal was the preferred god for exorcism because of his mastery over the sea and the monsters therein:
Baal is the champion of exorcists because he had defeated Sea and Death with their monsters. (p.183)