Please help. i'm struggling with a line printing one word before and one word after the match. ideally is to make number of words variable, but at lease 1 is needed.
sample Input
https://suttacentral.net/sn45.78-82 1 Saṁyutta Nikāya 45.78–82 8. Dutiyaekadhammapeyyālavagga Sīlasampadādisuttapañcaka
sn45.78-82 yathayidaṁ, bīṁāṅñhikkhave, chandasampadā …pe…
https://suttacentral.net/sn45.8 4 Saṁyutta Nikāya 45.8 1. Avijjāvagga Vibhaṅgasutta
sn45.8 Idha, bhikkhave, bhikkhu anuppannānaṁ pāpakānaṁ akusalānaṁ dhammānaṁ īṁāṅñanuppādāya chandaṁ janetīṁāṅñi vāyamati vīriyaṁ ārabhati cittaṁ paggaṇhāti padahati,
expected Output
bīṁāṅñhikkhave, chandasampadā …pe…
īṁāṅñanuppādāya chandaṁ janetīṁāṅñi
i don't know how to deal with symbols like **ī ṁ ā ṅ ñ ** etc
word related regexs don't handle these symbols properly
what i use
pattern=chand
grep -oP '(?:\s*\D?\s*){0,'10'}'"$pattern"'(?:\s*\D?\s*){0,'10'}'
what i get
ve, chandasampadā …pe…
▒ya chandaṁ janeti
please advice some solution. Grep, sed, awk, whatever available on default centos (can't install other utils)