The woman was walking along Agbrigg Road in Agbrigg, Wakefield, when Andrew Riley subjected her to a random attack, Leeds Crown Court heard.
Prosecutor, Richard Walters said Riley, 32, ran up to the woman and punched her in the face, knocking her to the floor just after 2pm on April 16 last year.
The court heard Riley, of Church View, Agbrigg, dragged her along the ground before running off.
Around five minutes later, Riley returned to Agbrigg Road brandishing a large silver knife.
Mr Walters said: “He was shouting and waving the knife at people and passing cars and making stabbing gestures.”
Riley admitted assault and possessing the knife.
Handing Riley a four-month prison sentence suspended for 18-months, Judge Robin Mairs told him: "It was a random attack which must have been utterly terrifying for her."