Sunan Abi Dawud, Book 26, Hadith 24 (Abu Dawud 3665)

Narrated Abu Hurayrah:

The Prophet (ﷺ) said: If anyone acquires knowledge that should be sought seeking the Face of Allah, but he acquires it only to get some worldly advantage, he will not experience the arf, i.e. the fragrance, of Paradise.