2 Samuel 5:17-25 ESV
When the Philistines heard that David had been anointed king over Israel, all the Philistines went up to search for David. But David heard of it and went down to the stronghold. Now the Philistines had come and spread out in the Valley of Rephaim. And David inquired of the LORD, “Shall I go up against the Philistines? Will you give them into my hand?” And the LORD said to David, “Go up, for I will certainly give the Philistines into your hand.” And David came to Baal-perazim, and David defeated them there. And he said, “The LORD has broken through my enemies before me like a breaking flood.” Therefore the name of that place is called Baal-perazim. And the Philistines left their idols there, and David and his men carried them away.
And the Philistines came up yet again and spread out in the Valley of Rephaim. And when David inquired of the LORD, he said, “You shall not go up; go around to their rear, and come against them opposite the balsam trees. And when you hear the sound of marching in the tops of the balsam trees, then rouse yourself, for then the LORD has gone out before you to strike down the army of the Philistines.” And David did as the LORD commanded him, and struck down the Philistines from Geba to Gezer.
ESV: English Standard Version 2016