GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  UNIX
Go To First  |  Previous Question  |  Next Question 
 UNIX  |  Question 58 of 61    Print  
Grep
How to use logical AND in grep?


  
Total Answers and Comments: 1 Last Update: December 12, 2008     Asked by: nayakss 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
December 12, 2008 03:09:27   #1  
UncaAlby Member Since: October 2008   Contribution: 13    

Logical "AND" with "grep" command
By logical "and" I presume you mean that you wish to see lines that contain both "expressionOne" AND "expressionTwo".

Just pipe the standard output of one "grep" command into the standard input of a second "grep" command.

E.g.:

echo "Good Bad and Ugly" | grep "Good" | grep "Bad"

will print the line. It is paradoxically both "Good" AND "Bad".

echo "All Good Men Must Sleep" | grep "Good" | grep "Bad"

will print nothing. "Good" AND "Bad" is false.

A thornier question (which you didn't ask) is how to do a logical "OR".

 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : grep is used for pattern searching in files ...

How to use logical AND in grep? 
Latest Answer : By logical "and" I presume you mean that you wish to see lines that contain both "expressionOne" AND "expressionTwo".Just pipe the standard output of one "grep" command into the standard input of a second "grep" ...
Read Answers (1) | Asked by : nayakss


 Sponsored Links

 
Related Articles

How to call C header that is not provided generally by system in C++?

Headers can be called by using extern C Syntax of extern C is: extern "C" <function declaration> for example to call C functions from C++ we can write extern "C" { <function declaration> <function declaration> ...
 

System Implementation

In the previous articles relating to SDLC Stages we discussed about Project Planning and Feasibility Study moved on to System Analysis and Requirements which lead to Systems Design. Systems Design will naturally lead to another stage where it becomes closer to the actual deployment of the p
 

System Analysis and Requirements

In the previous chapter, we’ve discussed about project planning and feasibility study. That stage was important because it tries to establish a problem in our highly technological world. As our understanding on what we can do in computers evolve and so are the things that we need to make t
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

Operating Systems and IT Certification

With the burst of information technology that is becoming a part of the dominant culture throughout the world, are programs that are designed to help those in this area to grow in knowledge.  By understanding the different technologies that are available, one is able to use them and impleme
 

Unix Client Server Technology

Unix Client Server Technology Understanding the Role of Unix When discussing client server technology it is important to understand UNIX one of the first primary building blocks for network possibilities that continues its influence today UNIX is an operating system designed for multi tasking by mul
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

How To Determine If Your CRM System Will Fail

How To Determine If Your CRM System Will Fail One of the primary reasons why many CRM systems fail is because of the quality of the data Even if you are using a high end CRM system your company will have no chance of success if it is processing data that is incorrect or faulty Fortunately data quali
 

HR Interview - HR Interview Mistakes You Will Want To Avoid

HR Interview Mistakes You Will Want To Avoid The job interview can be a stressful process This is especially true for those who are going after a competitive position Your nonverbal communication combined with the answers you give during the interview will determine if you are hired mosgoogle While
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape