Those end-caps are quite reusable.
If you take a pair of pliers and squeeze it gently so that the flattened portion opens up you can then slide it back onto the cable.
Using the pliers you can then re-crimp it on the cable.
Although it looks ugly and everyone will know that you are too cheap to buy a 10c end-cap.
A little bit of superglue placed at the end of the cut seems to help keep the individual wires from separating.
bicycles.stackexchange.com/users/4015/Ritch Melton
You could maybe cut it where it is not frayed and put a cap if the slack is long enough.
Or you could put a piece of duct tape just to avoid the fraying from reaching a place interfere with the derailleur.
Or you could try to gather the frayed-out strings and put a cap anyway Or if you really don't like it
, you can change the cable completely though it is overkill.
bicycles.stackexchange.com/users/5526/tisek
If you have an unneeded old wheel laying around, use a spoke nipple.
Remove the nipple from the spoke slide it over the cable and crimp with pliers.
bicycles.stackexchange.com/users/3083/mikes
I have successfully used A tiny bit of epoxy glue.
Another option is a bit of tin soldering wire: give it a couple of tight loops around the end of the cable then squash it with pliers.
Tin is soft enough to be defformed around the cable without deforming the cable.
Yet another option is to use an actual soldering iron to cover the very last centimeter of cable with tin.
It is quite difficult to solder the end of the already installed cable though.
If the cable is not too badly frayed it can be de-frayed with pliers, grabbing all the strands and twisting it in the right direction.
Do it before applying the cap end substitute.
bicycles.stackexchange.com/users/2177/Jahaziel
I've used a cable crimp.
It looked terrible but it prevent the cable from unravelling before I got to the bike shop to discover that a bike shop will usually give you those end caps if you buy something else from the store.
The shops have them in the thousands and they probably paid about $3 for them.
bicycles.stackexchange.com/users/6474/Josh Smith
I've used these cable connectors before...
you just break one off and screw it over the cable end.
They work great and look pretty "impressive".
bicycles.stackexchange.com/users/20344/Freddie S
You could use some heat shrink tubing ( example ) to keep the frayed cable together.
If you don't have a heat gun, most heat shrink tubing can be shrunk with a hot hair dryer.
bicycles.stackexchange.com/users/22576/Adam
In a pinch, use wirenuts .
They're available at hardware stores.
The smaller ones work better as a cable end-cap.
bicycles.stackexchange.com/users/2123/Jim Fred
If you have slack in the cable, cut the frayed end and cap as usual.
If you don't have enough slack, use JB Weld to prevent further unraveling.
Work it into the fibers, and wrap with duct tape to hold tight while it cures.
bicycles.stackexchange.com/users/7099/Jonathan
Cut a bit of cable housing, peel the plastic, and squeeze as you would a conventional cap (using more force, though).
Doesn't look bad but is no substitute for actual end caps.
bicycles.stackexchange.com/users/22535/emagar
I was adjusting the tension of my front derailleur cable and managed to pop off the cable end cap. The cable is now quite frayed at the end and I think it would be difficult to attach another cap.  What would work as a suitable replacement for a cap? I've read that perhaps superglue or duct tape could work?
What is a good replacement for a cable end cap?
bicycles.stackexchange.com
<cable>
bicycles.stackexchange.com/questions/15930
bicycles.stackexchange.com/users/6182/Robert Dougan
End-caps are quite reusable. If the cable is not too badly frayed it can be de-frayed with pliers, grabbing all the strands and twisting it in the right direction. A little bit of superglue placed at the end of the cut seems to help keep the individual wires from separating. Other options include using a soldering iron, using the spoke nipple from an old wheel, a cable crimp or epoxy glue,  It may be possible to replace the cap or use another if you repair the frayed part. Superglue or twisting can be used to keep the ends together, or you can cut off the frayed part or even replace the cable. Other options include sealing the end with superglue, epoxy or solder, covering with electrical cable sheath or heat shrink tubing or using a cable crimp or cable connectors.
It may be possible to replace the cap or use another if you repair the frayed part. Superglue or twisting can be used to keep the ends together, or you can cut off the frayed part or even replace the cable. Other options include sealing the end with superglue, epoxy or solder, covering with electrical cable sheath or heat shrink tubing or using a cable crimp or cable connectors.