I have the problem that I have to deal with a set of data given in a JSON/CSV file. I am having four items per entry and one of them has ±5000 characters. I need only a certain range of information that is located around a search word.

How can I filter out ~100 characters before and after a specific search word?


If you want to see 100 characters before and after the word you’re searching for, do

grep -oE '.{0,100}word.{0,100}' file
grep –o '.\{0,100\}word.\{0,100\}' file

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.