Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-09-2012, 02:54 PM   #1
LQ Newbie
Registered: Apr 2012
Posts: 1

Rep: Reputation: Disabled
Checking for multiple patterns in Unix


I writing a shell script to find if an object is merged to CVS head or not.Currently I am running a CVS command using the script to get an output to check the same.

eg. If the output has three specific tags... you come to know that its merged to head. If it has two or less, the code is not merged to head.

My intention is to automate the script further and get a refined output.

eg. I need help in writing a script that gives me an output "Merged to HEAD" if it finds the three tags in the output file and vice vera.

Old 04-09-2012, 03:29 PM   #2
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,569

Rep: Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130
Something like:
egrep 'tag1|tag2|tag3' file

If that's the grep you're looking for, you can then pipe it into "wc -l" and do a quick test to see if it's less than 3.
Old 04-10-2012, 08:46 AM   #3
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
Instead of just posting a vague description of your text and requirements, how about posting an actual example of the input, the desired output, and any code you've tried using so far?

The more (relevant) details you give, the less time we'll have to spend guessing what you mean, and the faster you'll be able to get the help you need.

How To Ask Questions The Smart Way


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Search multiple patterns & print matching patterns instead of whole line Trd300 Linux - Newbie 29 03-05-2012 07:41 PM
Excluding multiple patterns from grep flamingo_l Linux - General 9 01-06-2011 08:05 AM
grep for multiple patterns???? lucastic Linux - Software 4 08-06-2010 06:07 PM
searching multiple patterns through Vi editor barunparichha Linux - Software 10 05-12-2009 08:39 PM
If condition for checking patterns in multiple files rattlesnakejoe Programming 5 05-07-2009 02:52 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:56 AM.

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