help again


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help again
# 1  
Old 10-22-2008
help again

I need help on how to do this.

1. grep for a string and print the third line above it
2. grep for a string and print the seventh line below it.
3. grep for a string and print third and seventh line.


Thanks
# 2  
Old 10-22-2008
This looks like homework - and it requires gnu grep. Please do not post homeoiwrk on these forums.

Code:
grep -A <num of lines above it>  string filename | head -1
grep -B <num of lines below it>  string filename | tail -1

You can work out how to combine those.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question