higlighting strings while searching

Hello experts,

i am using sun solaris 9

i try to searching string from a file using more command.

I wish when i search a string it will higlight the string/strings from the file.

Have any idea how to do it..?

I use putty.

br//purple

Use 'less' instead of 'more'

More or less, it's better to use more of less and less of more. Less simply is more.

try

strings <file> | grep <search_string> | more

Except that gets complete lines of strings. Maybe he wants each word to be picked out?

tr ' ' '\n' <file> | grep <search-string> |more

Also, GNU grep has a highlight option. You can use this to hilight the matches on the output. If you want to view it with less, you need to tell it to not squelch escape sequences with "less -r".

i tried all of your above method. execpt "less" which is not supported in my solaris.

just to clarify i need like below-

as an example-

$more filename

this is my file containg 989878
this is my file containg 777677
/123456
this is my file containg 123456
this is my file containg 000000

as above it will highlight the 12346 string. For this do i need any special client program ? i am using putty

less is indeed supported, but you might need to install one of the SFW (from Sun) or CSW packages. For terminal emulation to work right with putty, you need to set your TERM variable either to either: vt100, vt102, ansi, or xterm. Putty should work fairly well without configuration changes with any of these.

well other than "less" anything else u can advice

Use perl to replace the functionality of GNU grep --color and pipe that into more:

$!/bin/ksh
perl -e '$re=shift @ARGV; while (<>) { s/($re)/\e[7m$1\e[0m/og; print; }' "$@" |more ;
}

This script will act like grep: you provide a regular expression and list of files (or it reads from standard input). You will not be able to pass any grep-like options (ie, if you need -l or -n, you'll have to do more complex argument handling, hard-code it in the regexp; if you need case-insensitivity, you can include it in the perl regular expression).

less -p STRING filename.

-p: the pattern to search.