Deuteronomy 20:7-17

7 Or if any man is newly married and has had no sex relations with his wife, let him go back to his house, so that in the event of his death in the fight, another man may not take her.
8 And let the overseers go on to say to the people, If there is any man whose heart is feeble with fear, let him go back to his house before he makes the hearts of his countrymen feeble.
9 Then, after saying these words to the people, let the overseers put captains over the army.
10 When you come to a town, before attacking it, make an offer of peace.
11 And if it gives you back an answer of peace, opening its doors to you, then all the people in it may be put to forced work as your servants.
12 If however it will not make peace with you, but war, then let it be shut in on all sides:
13 And when the Lord your God has given it into your hands, let every male in it be put to death without mercy.
14 But the women and the children and the cattle and everything in the town and all its wealth, you may take for yourselves: the wealth of your haters, which the Lord your God has given you, will be your food.
15 So you are to do to all the towns far away, which are not the towns of these nations.
16 But in the towns of these peoples whose land the Lord your God is giving you for your heritage, let no living thing be kept from death:
17 Give them up to the curse; the Hittite, the Amorite, the Canaanite, the Perizzite, the Hivite, and the Jebusite, as the Lord your God has given you orders: