Terrence McCann, 46, is on trial at Shrewsbury Crown Court for allegedly having a bladed weapon while imprisoned at HMP Stoke Heath near Market Drayton in June last year.
McCann was searched after he punched a prison officer, less than an hour after he arrived at Stoke Heath, the court heard. He had been transferred from HMP Liverpool earlier that day.
Several officers who worked at Stoke Heath gave evidence at the trial on Thursday, including Joe Dunworth who said he became aware of McCann when he pushed into a meal queue at about 4.40pm on June 18 2018.
Mr Dunworth said that he and his colleague Peter Doherty confronted McCann, who became abusive and started making derogatory anti-Scottish remarks about Mr Doherty.
"He was very aggressive in his demeanour," said Mr Dunworth. "He was looking me up and down as if he was going to strike somebody."
McCann went into a cell in the prison's G wing and the officers followed him. He swung a punch at Mr Doherty's arm and a struggle began, said Mr Dunworth.
McCann was restrained by Mr Dunworth, Mr Doherty and a third officer, and eventually calmed down. Shortly after the confrontation he was searched and the improvised metal weapon found.
Prosecuting barrister Rob Edwards questioned Joseph Draper, who along with a colleague was responsible for searching McCann after the altercation in the cell.
Mr Draper said that he and the colleague were searching McCann for contraband in the prison's 'segregation and reintegration' unit.
He told the trial: "We asked Mr McCann to remove his tracksuit bottoms, to which he did.
"When he pulled his trousers down [the weapon] fell from the waistband of his trousers. The bladed article fell between us."
In court Mr Draper was shown the weapon, a sharpened piece of metal with tape added to make a handle, and agreed it was the same one that fell from McCann's person.
He said that when he realised what it was he shouted 'blade' and slid it away with his foot.
Nick Cockrell, for McCann, cross-examined the prison staff who gave evidence. He suggested to Mr Dunworth that McCann never pushed into the meal queue, saying it "simply didn't happen".
He said that Mr Doherty had been aggressive to McCann and was trying to "lay down the law", and that McCann had bruises on his head afterwards.
Mr Dunworth said again that McCann had pushed in, and that himself and Mr Doherty had followed best practice throughout.
Mr Cockrell asked Mr Dunworth if he planted the weapon on McCann, a notion which he called "ludicrous".
McCann, of Liverpool, denies having an offensive weapon and the trial continues.