LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices

Reply
 
Search this Thread
Old 10-18-2007, 05:44 AM   #1
LinuxLover
Member
 
Registered: Feb 2004
Distribution: Solaris 10/11 , RHEL 6 ,AIX 7.1
Posts: 185

Rep: Reputation: 32
how to grep multiple filters with grep




# cat /etc/hello_word |grep abc


This command will filer word abc from the file hello_world

How can I filter multiple world with command e.g.
I want to filter two different words abc and xyz from this file.
 
Old 10-18-2007, 07:12 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Bash "alternation operator"---a fancy way of saying "or"

cat filename | egrep '(abc|xyz)'

egrep because we're using an extended regular expression

For the purists, the most efficient command is:

egrep '(abc|xyz)' filename
 
1 members found this post helpful.
  


Reply


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
grep multiple strings GEEXTER Linux - General 7 12-06-2013 09:56 PM
grep for multiple patterns???? lucastic Linux - Software 4 08-06-2010 06:07 PM
need to search (grep) multiple directories red_nexus Linux - Newbie 5 07-04-2006 10:44 PM
Using grep to change multiple files zwyrbla Linux - General 5 01-11-2005 02:14 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM


All times are GMT -5. The time now is 09:44 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration