Michael Hill, 23, forced his way into a house in Haddington, in East Lothian, and launched an attack on Kieran Cooper, repeatedly striking him with the weapon.
The victim’s 68-year-old grandfather, Alan Cooper, managed to get Hill out of the property in Lynn Lea Avenue but the assailant returned and struck him with a bag and began repeatedly kicking him on the head when he fell to the ground.
A judge told Hill at the High Court in Edinburgh that his offences were “a very grave course of violent, criminal conduct”.
Lord Arthurson said he had inflicted sustained violence on Kieran Cooper with a large, bladed weapon and a substantial custodial sentence was appropriate.
The judge told him he would have faced a sentence of seven years imprisonment, but for his guilty pleas.
Hill, also from Haddington, earlier admitted assaulting Kieran Cooper to his severe injury, permanent disfigurement and to the danger of his life on August 8 last year by forcing his way into the house, pursuing him, struggling with him and wounding him with the knife.
He also admitted assaulting Alan Cooper to his injury by striking him on the head with the bag and repeatedly kicking him after he fell.
The court heard that apprentice plumber Hill had turned up in the street asking where Kieran lived before going to the address where the attacks occurred.
Mr Cooper, 23, answered the door to him and Hill began shouting at him about having a relationship with his sister and immediately tried to strike him on the face with the knife.
Mr Cooper tried to shut the front door on him but Hill kept forcing his way into the house and chased him into the kitchen area and repeatedly stabbed him.
After hearing a disturbance and shouting the victim’s grandfather came downstairs and saw his grandson holding his upper left arm with blood running down his side and a large amount of blood in the kitchen.
He took hold of Hill who shouted: “Get your hands off me or I will stab you too.” He managed to get him out the front door but he returned and swung the bag at him and struck him on the side of the face.
After the attacks Hill walked off and a witness found a knife with an eight inch serrated blade left at the scene.
Emergency services were called and when police arrived they noticed blood in the kitchen and on the floor which led through to the living room where the stab victim was found.
The grandson was taken to Edinburgh Royal Infirmary and found two have two penetrating wounds to the chest and further wounds on his left bicep. A chest drain was inserted and his injuries were stitched up. The grandfather was found to have sustained cuts, scratches and bruises.
Defence lawyer David Nicolson said Hill was “a decent, young man from a decent, hardworking, supportive family”.
He said that Hill had shown genuine remorse and was assessed as posing a low risk of re-conviction.
Mr Nicolson said: “There is no established pattern of offending on his part and certainly no established pattern of violence on his part.”
Sign up to our newsletter: enter your email in the box at the top of this article to get daily updates straight to your inbox.