Article
Applies to:
- SUSE Linux Enterprise Server 9
- SUSE Linux Professional 9.2-9.3
- SUSE Linux 10.0
- Novell Linux Desktop 9
PROBLEM: Often times while administering your servers, you'll need to go through pages of text logs looking for a certain word, IP address, or other text. Sure, you could use the long time favorite, grep, but that only will present you with the line containing the data you need. Sometimes you will need to see the surrounding lines as well.
SOLUTION: For me, the solution was to be able to colorize an IP address or username (or any other text) from my log file (or any other text file). The solution is quite simple.
Copy this one-line script into an empty text file, somewhere in your path:
-
perl -p -e 's/'$1'/\e[31m'$1'\e[0m/'
I save it as "highlight" but of course you are free to name it whatever you like.
EXAMPLE: Use it like this at a command prompt:
-
cat filename | highlight SEARCHWORD
For example, if I wanted to see instances of the word "kernel" in my system log, I'd type:
-
cat /var/log/messages | highlight kernel
Give it a try!
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 3226 reads


0