Here's a quick entry on how to have a highlighted and colored text from grep resulting strings and characters.
Assuming we have /var/log/maillog and we wish to grep it with multiple search strings. Well this would be faily simply
# cat /var/log/secure | grep 'Accept\|refuse'
What if we want to make resulting matching grep strings appear in colored text or highlighted text. Highlighted and colored characters or words appear much more highlighted and distinguished specially when you are viewing large number of text lines from a log file.
Here's how to set and kick the ball.
Say from root terminal, simply issue
# alias grep='grep --color=auto'
And try issuing the later command again like so
# cat /var/log/secure | grep 'Accept\|refuse'
Make permanent between reboots for user root.
# echo "alias grep='grep --color=auto'" >> /root/.bashrc
Could be useful on tailing and grepping log files when needed.
Quick and easy. Enjoy.
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2008
(2301)
-
▼
February
(25)
- HowTo: Extract Lines That Started With Matching St...
- HowTo: Delete All Thumbs.db Recursively
- HowTo: Handy Linux Network Diagnostic Tool
- HowTo: Display Lines That Starts With A Given String
- HowTo: Find And Count JPG Files Recursively
- HowTo: Do Awk with Loop
- HowTo: Strip Out First Word of Line from Text Files
- HowTo: Highlight Matching Grep Results
- HowTo: GNOME Commander File Manager
- HowTo: Install Plone CMS on Fedora
- HowTo: Thumbnail A Website From Linux Command Term...
- HowTo: Advanced Two-Pane File Manager
- HowTo: Two-Pane GUI File Manager
- Slash Proc - File System Utilities
- HowTo: Drop Down Linux Terminal Console
- HowTo: Image Magics with ImageMagick
- HowTo: Convert JPG Image Files to MPG Video Files
- HowTo: Alternative Way to Convert GIF to PNG
- HowTo: Lock X While Root With ScreenSaver
- HowTo: Encrypted Bandwidth-Efficient Linux Backup ...
- HowTo: Install Java IcedTea on Fedora 8
- HowTo: Simultaneous Install of Sun Java and Java I...
- HowTo: Install K9Copy on Fedora
- HowTo: More of Fedora Themes Package
- HowTo: European Language Fonts Installation on Fedora
-
▼
February
(25)
Saturday, February 23, 2008
HowTo: Highlight Matching Grep Results
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment