Reputation: 15
I have a large xml file that is concatenated on one long line. What is the best way to search for a word without loading the entire file into memory at once? grep prints out the entire line, which in my case is the entire 500MB file.
The end result would be to see that word and the contents around it to understand it's context.
Upvotes: 0
Views: 39
Reputation: 1270
For example, you want to see the word three
and one another word around it:
$ echo "one two three four five four three two one" |egrep -o '\w+ three \w+'
two three four
four three two
Upvotes: 1