Reputation: 399
How to grep a word in 100 to 200 lines from file using grep and sed?
Upvotes: 1
Views: 290
Reputation: 80423
If you don’t mind using perl instead, the most straightforward solution is
$ perl -nle 'print if 100 .. 200 && /regex/' somefile
Upvotes: 0
Reputation: 8756
grep "word" file(s)
for instance
grep word *
searches for word in all files in the current directory. To print 100 -200 line do
sed -n '100,200p'
So combined you get
sed -n '100,200p' *|grep word
Upvotes: 2