Unplug the fan. Even if the fan isn't operating, electrical current is still flowing through the wire. If the cord was damaged to the point where the wiring is exposed, it should have been unplugged immediately.
Open the housing that covers the motor and wiring for the fan.
Locate the screws that the wires from the plug are attached to. Write down which color wires (black, white and green) go to which screws on the fan, then loosen the screws and disconnect the wires.
Loosen the screws on the cable connector which holds the power cord in place inside the fan housing, and pull the old cord out of the fan.
Slide the new power cord into the fan and through the cable connector, and tighten the screws to lock the cord in place. Position the cord so the wires inside the cord can reach the screws on the fan.
Connect the black, white and green wires inside the power cord to the correct screws on the fan, following the diagram you made when removing the old wires. If the wires have eyelets on the ends, slide them over the screws and tighten the screws. If there are no eyelets, bend the ends of the wires into a hook with a pair of pliers, then hook them over the screws and tighten the screws.
Replace the fan housing.
Plug in the fan and test it.