´It was narrated that Abu Hurairah said:` "The Messenger of Allah said: 'Whoever acquires knowledge by which the pleasure of Allah is sought, but he only acquires it for the purpose of worldly gain, will not smell the fragrance of Paradise on the Day of Resurrection.'" (Hasan) Another chain with similar wording.
Hadith Referenceسنن ابن ماجه / (أبواب كتاب السنة) / 252
Hadith Gradingالألبانی:صحيح | زبیر علی زئی:إسناده حسن