This is likely to be better solved on the server itself.
The ‘traditional’ option is to use a pager, which is a program that simply displays the contents of a file and allows you to easily navigate around them. less
is the de-facto standard option for this on most UNIX-like systems, though there are plenty of other options. Pretty much all decent pagers (read as ‘almost anything other than more
and it’s direct clones) let you search in the file in some way (in less, hit / and then type in any POSIX basic regular expression) and jumping to specific lines, and many support more complex navigation (such as jumping to matching parenthesis or braces). Normal pager programs either take the text to display on standard input, or display whatever file you pass as an option.
A slightly more typical approach these days is to open the file in whatever text editor you normally use, and search that way. Some text editors even have specific read-only modes for this usage (for example, Vim's view
alias).
Better yet than either approach though is to use a tool like GNU screen or tmux to get a configurable scrollback buffer on the server itself, which can be searched directly on the server, or can be saved to a file if you want. This also gets you a bunch of other useful features, such as being able to resume interrupted SSH sessions (by just reattaching to the existing session) and having multiple shells or programs open at the same time on one session.
grep
does, no?-A
and-B
parameters togrep
. For example,grep -B 3 -A 10 foo
will give you the three lines before and ten lines after each occurrence of "foo".grep -C 5 foo
for 5 lines either way. It's shorter, so I tend to use that more.