LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - News > Syndicated Linux News
User Name
Password
Syndicated Linux News This forum is for the discussion of Syndicated Linux News stories.

Notices


Reply
  Search this Thread
Old 06-20-2014, 08:41 AM   #1
LXer
LXer NewsBot
 
Registered: Dec 2005
Posts: 128,372

Rep: Reputation: 118Reputation: 118
LXer: Scripting a 4-Color Multiple Grepper


Published at LXer:

I wrote the shell script described here ('grep4') to find up to four items at the same time in my data tables, which are big text files with one record per line. The script gives each searched-for item its own color on the terminal screen. It lets me know in advance how many 'hits' there are, so that if there are lots of hits, I get the choice of printing the results to a file instead of displaying them. The script also lets me choose between seeing all records with any of the items (the OR case: A or B or...) or just the records containing all the searched-for items on one line (the AND case: A and B and...).

Read More...
 
Old 06-20-2014, 09:11 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
I wrote a shell script that does this as well:

Code:
grep 'pattern1\|pattern2\|pattern3\|pattern4' filename | wc -l; \
echo "print to screen or file?"; read I; if [ "$I" == "screen" ]; \
then  grep --color 'pattern1\|pattern2\|pattern3\|pattern4' filename; \
else grep 'pattern1\|pattern2\|pattern3\|pattern4' filename > output; fi
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LibreOffice Writer: How to color single cell with multiple colors ghantauke Linux - General 1 09-21-2012 08:56 PM
LXer: Scripting the Linux desktop, Part 2: Scripting Nautilus LXer Syndicated Linux News 0 02-17-2011 04:02 AM
[SOLVED] Bash Scripting - Output as Multiple Files zer0signal Programming 14 01-26-2011 06:43 PM
bash scripting: using color in dialog dansku Programming 4 01-22-2010 08:16 AM
multiple color support in aterm ????? UsualTuxpect Linux - Software 6 08-27-2004 09:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - News > Syndicated Linux News

All times are GMT -5. The time now is 01:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration