A bayonet ( from French baÃ onnette ) is a knife - or dagger-shaped weapon . It is designed to be attached to a rifle barrel or similar weapon . A bayonet ( from French baÃ onnette ) is a knife , dagger , sword , or spike-shaped weapon designed to fit in , on , over or underneath the muzzle of a rifle , musket or similar weapon , effectively turning the gun into a spear .