Al-Adab Al-Mufrad, Book 42, Hadith 47 (In-Book)

Abu Hurayra said, "Whoever meets his brother should greet him. If a tree or wall comes between them and then he meets him, he should greet him on the other side."

حَدَّثَنَا عَبْدُ اللهِ بْنُ صَالِحٍ قَالَ‏:‏ حَدَّثَنِي مُعَاوِيَةُ، عَنْ أَبِي مَرْيَمَ، عَنْ أَبِي هُرَيْرَةَ، أَنَّهُ سَمِعَهُ يَقُولُ‏:‏ مَنْ لَقِيَ أَخَاهُ فَلْيُسَلِّمْ عَلَيْهِ، فَإِنْ حَالَتْ بَيْنَهُمَا شَجَرَةٌ أَوْ حَائِطٌ، ثُمَّ لَقِيَهُ فَلْيُسَلِّمْ عَلَيْهِ‏.‏

sunnah.com