Achoo: The cow can be a bit blunt with her descriptions of the other animals' misbehaviour, but she means well.
The Adventures of Pinocchio: Pinocchio himself is not the friendliest person ever, but he is still a selfless "boy" who would help unknown people and even antagonists provided they haven't done a grave fault. It is also clear that he loves his parental figures. The Fairy states that Pinocchio is this, because he had wept over her supposed grave, noting that despite his faults he does have a heart and therefore he has a chance of redemption.
Henny in All-of-a-Kind Family is devious and likes to cause trouble for people, but nonetheless cares deeply for her sisters and baby brother. She was also quick to defend Guido, a young orphan boy who was being harassed by a shopkeeper, and when she conned a doll from a charity, she ended up giving it to a homeless girl.
In Gilbert's case this is actually something of a Subverted Trope. Among all the girls except Anne, it's widely understood that Gilbert is just a Nice Guy who teases the girls he likes (which is not uncommon for 11-year-olds).
There are also Mr. Harrison and Norman Douglas.
Artemis Fowl. Played straight from the second book onwards, where Artemis has moments of genuine concern for his allies, and the fairies go from being Enemy Mine to being friends.
Commander Root also fits the trope really well.
Ascendance of a Bookworm: When introducing an annoying Manchild named Sylvester to Myne, Ferdinand promises that he has a good heart under his terrible "everything else". This is confirmed when he gives up on an exchange of chefs after being told the chefs he wanted to obtain were trained to work in very new type of business their employer invested a lot in and later donates the meat from a hunt to an orphanage.
Also works with Jaime as the books progress. The jerk in him is easy enough to spot, but after reading his perspective, you realise that from his point of view, all he has ever done is really for love. He fiercely defends Brienne when someone insults her (when she isn't even there), will jump into a bear bit to save Brienne, and has the head of a girl's rapist presented to her. He also warns a man who is interested in said girl to only do something if she wants it.
In the Belgariad, Prince Kheldar (aka, Silk) is a spy/merchant/assassin/thief (usually simultaneously), is constantly throwing smartass remarks into people's faces, and he's known to purposely needle minor characters by talking about identified weak spots—whether it's purposely getting history wrong, or just exposing them to his own memorable personality. Likewise, Beldin likes annoying Belgarath, who is also capable of messing with people. It definitely says something about the average level of personal interaction in this universe that Polgara is the Team Mom of the bunch, despite having a personality abrasive enough to strip paint. On the other hand, they do care deeply about their friends and family, and don't (usually) don't indulge in gratuitious collateral damage.
In The Book of the Dun Cow, Chauntecleer the rooster's Hair-Trigger Temper causes him to constantly verbally abuse Mundo Cani, and he can sometimes be quite selfish. However, he is also the leader of the good guys and shows many times that he does care about his wife, land, and people.
Captive Prince: Prince Laurent is publicly known as a "cast-iron bitch" and is outright cruel to Damen at first, but has fleeting, carefully hidden moments of kindness. He has a good relationship with the palace slaves and, once they're alone, teaches a few tricks to a child who'd just lost a family member.
Several characters in Chronicles Of Magic; most notably being Skeeter Traps, who tends to show her concern for others via punching and insulting them.
Dedicate Rosethorn from the Circle of Magic books is irritable, snarky, refuses any and all help when she desperately needs it, and constantly threatens gruesome deaths on her charges. Yet she gives a great deal of herself helping others - nursing the sick and restoring medicines in Briar's Book, leaving Summersea to save the village in Melting Stones (never mind that she's just returned from a war and is completely spiritually exhausted). She also adores her student, Briar, however much she tries not to show it.
Tris also is like this, and so are some of the other teachers and secondary characters, like Dedicate Crane.
Lord Wyldon of Cavall from the Tortall Universe is a bit of a jerk towards women, believing that they should Stay in the Kitchen and putting Keladry of Mindelan on probation for her first year as a page, despite the law that says that noble girls can try for knighthood. On the other hand, he has a sense of honor and fair play, feels ashamed upon realizing that he almost refused to let Kel continue despite how good she was, and admits that she may be the best knight he ever trained.
In Claudius The God, Claudius describes his lifelong friend Herod Agrippa as "a scoundrel with a golden heart." His description of what this entails is classic Jerk with a Heart of Gold.
Courtney Milan's Cyclone series has Adam Fucking Reynolds - a billionaire tech entrepreneur who's foul-mouthed, foul-tempered, blunt, and hypercritical of everyone around him, a well-meaning but seriously imperfect father who kept his son in the spotlight from infancy, and a cocaine addict. Word of God is that his real-life models included Steve Jobs, Bill Gates, Larry Ellison, and Mark Zuckerberg. But, while his company has some ethical issues, he can usually be counted on to do the right thing in a real crunch, he's very receptive to criticism, and he has standards. (He's also a fan favorite verging on Memetic Badass.)
Superintendent Andrew Dalziel from the Dalziel and Pascoe novels and TV series. He comes across as your typical overweight northern alcoholic bigot; but if you serve under him, despite the verbal abuse you'll get, he'll do his damnedest to fight tooth and nail for you. He's is an overweight, apparently bigotted, sexist old-fashioned copper who insults just about everyone he meets. On the other hand, he will fight like hell to protect any member of his team, did everything he could to advance Peter Pascoe's career (in the novel where Pascoe's promotion to Inspector is announced, it is revealed that Dalziel kept the news back from him initially because Pascoe's friends had just been murdered and Dalziel wanted him to be in a position where he could enjoy the news) and took the announcement of Wield's homosexuality in his stride and did everything he could to protect him from a genuinely bigotted superior.
All three of the main protagonists in Deep Secret are this. Rupert is a self-centered workaholic who has a tendency to miss the forest for the trees, but it's partially to stop himself from caring too much about his job and becoming emotionally ruined. Maree is an Iron Woobie who's life is currently at a serious rough patch, who's developed an extremely prickly exterior to keep herself from hurting even more. And Nick is, well, fourteen. (But he also has an overbearing mother he's trying to push away.)
Commander Sam Vimes, of the Discworld City Watch, is reputed as a hard-faced, hardheaded, cynical, foul-tempered, arrogant thug. Yet even the most dangerous mob boss in the city respects him as a straight-arrow, unbribeable (and though this is helped by his being the wealthiest man in the city, he was giving half his pay before that to the widows and orphans of the Watch), almost painfully-upright man who always does the right thing and never lets the Watch overstep its authority. He is, in fact, one of the most powerful authorities in the city, who hates and distrusts authority — as the Patrician says, "practically Zen".
Invoked and demolished with regards to Albert, Death's manservant. "And it's no good thinking you can appeal to my better nature under this here crusty exterior, 'cos my interior's pretty damn crusty as well." He was the head of Unseen University at its most cutthroat, after all.
Despite her intimidating demeanor, Granny Weatherwax is a good witch, albeit with much reluctance. She's hard and sharp as flint, but that's because she likes to test people; as Tiffany Aching notes in A Hat Full of Sky, witches do their hardest work on "the edge" (between life and death, right and wrong, and so on), and "the edge is no place for people to break."
In Wintersmith, Granny makes very, very sure that Tiffany is out of sight before she takes in the kitten Tiffany left on her doorstep. She has a reputation to maintain.
Moist von Lipwig fits this to a degree (though he is more of a reformed Gentleman Thief), in that all his plans are self-serving, but he usually manages to do a ton of good deeds along the way. In Making Money, he reflects: "Am I really a bastard or am I just really good at thinking like one?"
Nobby. Vimes probably sums him up best when he describes him as someone you can trust with your life but you'd be daft to trust him with half a dollar.
Rincewind is sarcastic, can be a bit mean spirited and insists that he's a Dirty Coward who cares only about himself. However, he's "a good man at heart" and is not as selfish as he pretends to be.
Morris the talking cat is snarky, self-centered, and contemptuous of just about everybody. When he and Dangerous Beans, one of the talking rats of the troupe he travels with, are both killed, he sacrifices one of his nine lives to save Dangerous Beans. He notes that at least once he returns to the land of the living he won't remeber it, so he can keep up his own self-image.
Vidia from the Literature//Disney Fairies series is usually described as the nastiest fairy, and has been shown time and again to be condescending to others, and only care about herself. Yet in Fairy Dust and the Quest for the Egg, she shared the last of her dust to save Neverland, and has occasionally shown a soft spot for Prilla.
Taken much further in the movies. In Great Fairy Rescue, Vidia gets Tink captured by humans but feels regret almost immediately. She goes for help and leads the expedition to rescue Tinker Bell, admitting her mistake when they were almost at the house. Later, she pushes Tink out the way and is trapped in a jar, and when rescued by the same fairy that she saved earlier, she becomes a permanent member of Tink's gang.
Dragon and Damsel: Azrael the Third is temperamental, and gets angry if Bernadette brings up certain topics or investigates things personal to him. But he never attacks her, saves her life even after she entered his family tomb, and heals her wounds.
Edgedancer (a novella of The Stormlight Archive): Stump is unpleasant, off-putting and seems to really dislike the children she's supposed to take care of as the owner of an orphanage, often assuming that they fake illnesses to get free food and bedding. As it turns out, some of this is an act - she literally cannot take as many children as she should or would like to, because she has neither the space nor funding, so she tries to scare them away instead. Also, she's a burgeoning Truthwatcher and is unconsciously healing the children, which is why they always seem to "give up the act" after a few days.
The title character of Eloise. While certain parents take offence at her being The Prankster, in reality Eloise is shown especially in the adaptations as a caring, generous person, giving gifts to Plaza Hotel employees and the less fortunate.
Carrick from Flawed is rough around the edges and first treats Celestine coldly, but quickly warms up to her and proves to be a loyal, caring, and brave friend.
Both Alexander and Rachael from Fort Hope qualify. They start off as fairly unsympathetic figures, but they redeem themselves by the end of the novel.
Hank the Cowdog from the series of the same name isn't nearly as strong as he boasts he is, as smart as he boasts he is, or as charismatic as he boasts he is...but when the cards are down and someone's in danger, he still charges into battle as though he was.
Harry Potter has a number of examples, as a number of the "good guys" are still jerks on more than some occasions.
Severus Snape is somewhere between between this and an all out Jerkass, depending on your point of view. He's highly biased towards Slytherin, he holds a personal grudge against Harry due to being bullied by Harry's father and his unreciprocated love for Harry's mother, and routinely bullies his other students for no particular reason other than he's a jerk. However in the end, he was devoted to Dumbledore, saves Harry's life and eventually gets himself killed by Voldemort for the greater good. The good he does also come across as pretty weird when you consider that it (and basically his entire adult life) is based entirely around a girl he was in love with from the ages of 10-16, give or take.
He also holds a borderline homicidal grudge against Sirius Black in Prisoner of Azkaban. However, at the time, he still believes that Sirius betrayed (and thus indirectly killed) James and Lily Potter, so the outburst is likely attributed to his life-long love of Lily (Evans) Potter, Harry's mother. Then again, given that it was Snape himself who told Voldemort about the prophecy which placed a target on the Potters' backs, it would still be at least a little hypocritical of him to hold a grudge against anyone over this. In any event, his rivalry with Sirius is much tamer in all later moments in the books when he has been assured of Sirius' innocence, even going so far as checking up on Sirius' safety when Harry has visions of him trapped in the Ministry with Voldemort. Not to mention Sirius and James routinely bullied Snape throughout their time in school, and Sirius tried to feed Snape to a werewolf at one point, so they aren't starting from a great point.
Sirius Black and as his best friend, James Potter fit as well. Numerous flashbacks show them being downright cruel to Snape on numerous occasions, and Lily originally disliked James for being a bully. However they seemed to be relatively popular and well liked and actively fought against Voldemort and the Death Eaters during the First Wizarding War.
While not a huge jerk, Horace Slughorn seems to be rather more concerned about his influence and knowing famous people than being a decent person, as well as being a bit 'old fashioned' (He seems to find the idea of muggle-borns being really good witches novel but doesn't hold it against said witches and seems pleased by the surprise). However, his terrible guilt over revealing how to make Horcruxes to the young Tom Riddle as well as his willingness to personally fight Voldemort in the final book show that there's more to him than connections and influence.
Gremma, Dee's roommate, is Hot-Blooded and sarcastic, and tends to lean towards a "punch first, ask questions later" mentality. However, she's Dee's closest friend in the world, and steps up to the plate when Dee needs her help.
Cora is an Ice Queenwho once had someone killed for unknown reasons, but she's the Team Mom, and throws herself up against the Daemon, who she knows is dangerous when he's angry, to try and stop Riley from making a Deal with the Devil, a choice that Cora thinks will ruin her life. (Riley's desperate enough that she doesn't care, but it was nice of Cora to try.)
The Daemon himself. He's cold, aloof, cynical, and prone to flashes of frightening anger, but he's trying to prevent the world from being destroyed, and he has rare Pet the Dog moments that hint that does see the heartless troops as more than just a means to an end. In his case, it's more like a heart of bronze buried beneath several layers of ice, but still.
Hercule Poirot frequently comes over as a vain, arrogant, egotistical jerkass, but underneath it all has a genuinely kind, decent heart.
Mr. Rafiel in A Caribbean Mystery initially comes across as an impossibly rude old rich bastard, but turns out to be a surprisingly kind man under all his bluster. He and Miss Marple become fast friends over the course of the story. It also becomes clear that at least some of his rudeness and ill temper stems from poor health and chronic pain rather than his innate personality. He's well aware of his faults, and has a deep and genuine gratitude to those close to him for putting up with him.
Ford Prefect veers in and out of this trope - he's something of an asshole, but he did save his best friend Arthur from certain death and is passionately opposed to cruelty to any animal but geese.
Despite this, he did at one point (while trapped on Earth thousands of years in the past) take up cruelty to animals as a hobby, and has hinted that he is responsible for the shape of the giraffe's neck.
The Hunger Games: Katniss admits herself that she's not very friendly. There are quite a few times throughout the series where she has angry/rude outbursts. But they are often caused by the various stressful situations she's thrown into and the Crapsack World she lives in. Regardless, she still has a kind heart and would sacrifice anything in order to protect the people that she loves.
And Haymitch Abernathy has a prickly exterior that would put a cactus to shame, and is an unrepentant Deadpan Snarker, but under that, cares about all the Tributes he's mentored, and is part of the underground resistance to the Capitol.
Ronan Lynch from The Raven Cycle. He's a brooding, violent punk who will pick a fight with anyone, but he adopts a baby bird and loves his friends and family dearly (with the exception of his older brother, Declan).
Gabriel Lightwood from The Infernal Devices. He's surprisingly patient with Tessa while training her. Of course his Jerkass side comes out when he's frustrated and he is prone to taking out his anger on other people. He becomes much nicer in The Clockwork Princess when his father is turned into a demon as a result of demon pox and he is forced to stay at the Institite.
In The Long Earth, Lobsang is a very arrogant AI/reincarnated Tibetan mechanic, but ultimately does care for the safety and values the friendship of Joshua Valiente.
Max herself from Maximum Ride. She can be particularly rude and such to other people, but she undeniably cares about the Flock and her mom and biological sister.
Sir Gerald, father of Lord Peter Wimsey is an English country nobleman of the first water; a stubborn, reactionary, Hot-BloodedBoisterous Bruiser. However, when given the choice between his own life and that of an innocent woman (The woman is his mistress, and she is married to a deeply abusive man. Sir Gerald is accused of murder and she could provide him with an alibi, but then her husband would almost certainly beat her to death.) he chooses the former without hesitation. He is also extremely jerkish to Harriet Vane, but is so only out of concern for his son's well-being. Harriet is of significantly lower status than the Wimseys and has quite the reputation and he is afraid she might be a Gold Digger. Once he is satisfied that she really loves his son, he gives them permission to marry immediately and without comment.
The title character of the Mediochre Q Seth Series is an Insufferable GeniusDeadpan Snarker with no respect for anyone except himself and his friends. He is, however, shown to be respectful and considerate to those who are his friends. He has a sort of Foil in the minor character of Professor God (yes, he actually named himself after God), who also has a heart of gold but is so arrogant even Mediochre feels uncomfortable around him.
There are several examples among the prisoners in The Mental State, but Zack, the main character, is arguably the best example. He is perfectly willing to manipulate, humiliate and injure the people he supposedly cares about. It is difficult to tell how much he actually cares for people, being a sociopath, but there are several hints throughout the story that he is more sympathetic than he lets on. This is proven to be true in the final chapter in which he risks his life for someone he once loved.
Sachar in Oblomov. But he doesn't show his good side until his master, the title character, dies.
Harvey in the Origami Yoda books is this. Despite being rude to most of the other kids at his school, he joins them against Rabbski. The others are OK with this, albeit grudgingly.
Willie Woodley from Out of the Easy isn't the nicest person around, however, she does care for the protagonist Josie in a way that Josie's mother, Louise, never did.
Raffe from Penryn and the End of Days, acts aloof and belittling towards Penryn but towards the end of Angelfall, he does stupid things just to help her, up to and including risking his life at gunpoint to return her to her family.
There are many, many world-weary, cynical characters in Boris Strugatsky's The Powerless Ones of this World. While one of them is a genuine Jerkass, the others, despite having grown to be nasty old men that had explicitly given up on trying to achieve anything good or worthwhile with their superpowers, do at least come through to rescue the main character Vadim (a fellow pupil of "the Sensei") from a tight spot.
Project Tau: The scientist Renfield doesn't show the Projects any more sympathy or compassion than his colleagues do, but he's the only one who actively stops Dennison from going too far, and attempts to set things right for Kalin.
Simona Ahrnstedt's male protagonists have a tendency to be this. Seth in "Överenskommelser" and Markus in "De skandalösa" are especially prone to being jerks, but Gabriel in "De skandalösa" has his bad moments too. And yet, they always turn out to not be so bad after all...
Older Than Radio: Sherlock Holmes. Can be kind of a conceited asshole (especially toward the police detectives and poor Watson); but he more than once shows genuine kindness and concern for the wellbeing of his clients, and occasionally fails at hiding his genuine affection for Watson (particularly when Watson is hurt or endangered in some way). At one point he gives Watson a large sum of money by purchasing his medical practice for a very high price, but does it secretly through a relative so that Watson only learns of his involvement and generosity years later.
In Space Marine Battles, over-captain Vallax. He's a glory-stealing, egoistic jerkass, but has some (faint) sense of honor and wounds up comitting Heroic Sacrifice to save his men.
When Russell's sister Cheri is introduced in the second Spells, Swords, & Stealth book, she loudly complains about the lack of alcohol, mocks her fellow SS&S players' newbieish choices in their characters, and is more concerned with what kind of loot they'll get. In contrast to the Jerkasses that made up the gaming group from the first book, Cheri quickly warms up to the rest of the group and throws all her support behind Russell when he confides to her his suspicions that there's more than meets the eye in the modules he's been running.
In the Spilling Series by Sophie Hannah, several characters apply, but none moreso than Simon Waterhouse. Yes, he's arrogant, and his best friend Charlie describes him as "weird and frigid and socially inept", but when push comes to shove he generally is a good person and he does care about protecting innocent people, as well as CharlieZailer.
Captain Flint spends most of the first Swallows and Amazons book as an antagonist. Then the Swallows figure out who stole his manuscript (in the process clearing their own name) and he warms up to them considerably.
Time Scout's Skeeter Jackson is a thief and a Con Man who ruined people's vacations, even lives. Of course, he had a little bit of an excuse, but, in the end, he was just drifting. He stole, he gambled, he drank, and he gave most of his money to charity. Wait, charity?
Ripred the Gnawer (read: rat) from The Underland Chronicles is this. He's an antisocial semi-loner with only a small band of outcasts around him, and doesn't respect anyone unless they earn it from him. He has his moments, such as in Gregor the Overlander comforting Gregor after one of the quest members dies and he feels it's his fault, but in Gregor and the Code of Claw, we learn he had a family that drowned in an event described in Gregor and the Mark of Secret. He had a daughter, named Silksharp, that liked to do math puzzles and was apparently not very strong-bodied. Lizzie, the middle child of Gregor's family, reminds her of him. One of the moments of the book is him comforting Lizzie in the middle of the night after she has a panic attack.
Rose Hathaway from Vampire Academy is definitely not the most outwardly kind person, though in Blood Promise Sydney comments on how Rose seems so friendly and sociable towards her. She has no trouble insulting people, being Brutally Honest with Lissa, and exposing weaknesses in other people (like revealing the dirt-poor background of Mia Rialdi). Yet she also goes our of her way to protect the people she cares about.
In William King's Warhammer 40,000Space Wolf novel Ragnar's Claw, after the inquisitor tells the injured Ragnor that other Marines have repaired his gear, she tells him that one, Sven, said that he's not an armorer and Ragnar can do it himself next time, whatever the sergeant said. Ragnar laughs and assures her that Sven has a good heart under his harsh manner.
Jayfeather from Warrior Cats. He's quite grumpy and sarcastic to the cats around him, but he's completely loyal to his Clan and does care about his Clanmates.
Also Yellowfang. She's grumpy, and has a short temper, but the Heart of Gold is definitely there.
Clear Sky as well. Sure, first he takes a Level in Jerkass, but later on, his encounters with Gray Wing show there's still a heart
The Amyrlin gave an exasperated sigh. You remind me of my uncle Huan. No one could ever pin him down. He liked to gamble, too, and hed much rather have fun than work. He died pulling children out of a burning house. He wouldnt stop going back as long as there was one left inside. Are you like him, Mat? Will you be there when the flames are high?
Vivia of The Witchlands is abrasive, easily annoyed, and when informed that her brother has died, her first reaction is one of pure joy, as one more obstacle in her way has been removed. This being said, she's just as dedicated to the wellbeing of Nubrevna as Merik is, gives up food she's stockpiled for the poor of Lovats and is absolutely overjoyed upon learning that Merik is alive, not blaming him for his actions as Fury at all and helping him out the best she can.
Hareton Earnshaw of Wuthering Heights is a rude, boorish, illiterate young man prone to inarticulate outbursts of rage - but he has a hell of a Freudian Excuse (having been raised first by the violent alcoholic Hindley - who tried to kill him at age two by throwing him off a railing - and later by Heathcliff, who deliberately kept him as uncivilized as possible to ruin his life, and mocked and tormented his whole life by almost everyone he meets) - but in the end he's willing to stand up to Heathcliff and he ends up proving one of the more decent people in the book.