A Sheffield man who was found with a knife told police: "If you hadn't stopped me, I would've stabbed the person I saw," a court heard.
Sheffield Crown Court heard Jordan Mullins, aged 35, of Carrill Road, Fox Hill, pulled a kitchen knife out of his sock and placed it on a garden wall after initially speaking to police on Avisford Road, Southey Green on June 29.
Mullins made the shock admission to officers and was detained saying 'sorry' several times after initially flagging down the police car when it arrived at the scene.
On his arrest, Richard Thyne, prosecuting, said Mullins was acting in a 'extremely erratic' manner after taking his clothes off at the custody desk before carrying out a dirty protest on the cell floor and smearing it all over the walls.
Mr Thyne said: "Later in police interviews, he said he had found the knife and picked it up as he wanted to stop others from committing offences."
Recorder John Thackray said the case was 'extremely concerning' due to defendant's previous knife convictions.
Clare Walsh, defending, said her client accepted he would be sentenced for his crimes and added Mullins showed genuine remorse for what he had done.
Ms Walsh said Mullins had struggled with alcohol misuse.
Recorder Thackray said Mullins's knife offence posed a serious risk to the public.
"The possession of a knife in public is an increasing concern and it's a particular concern to me for your previous convictions which is an aggravating factor," he said.
"Your actions did pose a serious risk of harm to the public.
"I have taken into account your previous conviction but also the mitigation and the findings from the pre-sentence report."
Mullins pleaded guilty at the earliest opportunity to possession of a bladed article, criminal damage and possession of a small amount of cannabis.
Police found cannabis, worth £2.50, when Mullins was arrested after he was issued an arrest warrant for failing to attend Sheffield Magistrates' Court on September 4.
Mullins was jailed for eight months for the knife offence and one month for criminal damage. Recorder Thackray told the defendant he will serve the second half of his sentence on licence.