A year of drought struck me, so I entered one of the gardens of Madinah, rubbed some ears of grain, ate from them, and carried some away in my garment. The owner of the garden came, beat me, and took my garment.I went to the Messenger of Allah ﷺ, who said to the man, "You did not teach him when he was ignorant, nor did you feed him when he was hungry," or he said, "starving."He ordered him to return my garment to me and gave me a wasq, or half a wasq, of food.
حدثنا عبيد الله بن معاذ العنبري حدثنا أبي حدثنا شعبة عن أبي بشر
أصابتني سنة فدخلت حائطا من حيطان المدينة ففركت سنبلا فأكلت وحملت في ثوبي فجاء صاحبه فضربني وأخذ ثوبي فأتيت رسول الله ﷺ فقال له ما علمت إذ كان جاهلا ولا أطعمت إذ كان جائعا أو قال ساغبا وأمره فرد علي ثوبي وأعطاني وسقا أو نصف وسق من طعام
[Its isnad is sahih]. Ibn Majah narrated it in Tijarat, chapter "Whoever passes by the livestock of a people or an orchard, may he take from it?" h: 2298, from the hadith of Shubah, with this same wording. Nasai also narrated it, h: 5411. Hakim graded it sahih in 4/133, and Dhahabi agreed with him.