Sunan al-Darimi 575
أَخْبَرَنَا أَحْمَدُ بْنُ عَبْدِ اللَّهِ، حَدَّثَنَا أَبُو شِهَابٍ، حَدَّثَنِي إِبْرَاهِيمُ، عَنْ أَبِي عِيَاضٍ، عَنْ أَبِي هُرَيْرَةَ ﵁، قَالَ: قَالَ رَسُولُ اللَّهِ ﷺ : «مَثَلُ عِلْمٍ لَا يُنْتَفَعُ بِهِ، كَمَثَلِ كَنْزٍ لَا يُنْفَقُ مِنْهُ فِي سَبِيلِ اللَّهِ»
Ahmad ibn ʿAbdullah informed us; Abu Shihab narrated to us; Ibrahim narrated to me, from Abu ʿIyad, from Abu Hurayrah, may Allah be pleased with him, who said: The Messenger of Allah ﷺ said: "The likeness of knowledge that is not benefited from is like a treasure from which nothing is spent in the way of Allah."