Solved

filter a list of processes without using grep -v

Posted on 2016-08-09
6
41 Views
Last Modified: 2016-08-11
I have a list of processes running on my server pasted out into a file and I want to filter out maybe 60 processes that i have in another list. Is there a better way of doing this than using grep -v ?
0
Comment
Question by:lolaferrari
  • 2
  • 2
  • 2
6 Comments
 
LVL 27

Accepted Solution

by:
serialband earned 250 total points
Comment Utility
Are you having trouble with the syntax?

grep -Ev 'Term1|Term2|Term3|Term4' filename.txt
egrep -v '(Term1|Term2|Term3|Term4)' filename.txt


grep -v -f exclude_list.txt filename.txt
1
 
LVL 11

Assisted Solution

by:tel2
tel2 earned 250 total points
Comment Utility
Hi serialband,

> "egrep -v '(Term1|Term2|Term3|Term4)' filename.txt"
What is the purpose of the "(" & ")" in this example?

Would you agree that this would give the same result:
    egrep -v 'Term1|Term2|Term3|Term4' filename.txt

I would have thought that the () would only be useful if you also had something outside of them, e.g.:
    egrep -v 'The (Term1|Term2|Term3|Term4) is' filename.txt

tel2
0
 

Author Comment

by:lolaferrari
Comment Utility
I just thought there might have been a better way to filter things out than using egrep -v ('...') You see I might have as many as 40 or 50 items that I want to filter out and I just wondered if there was another way to do it.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 11

Expert Comment

by:tel2
Comment Utility
Hi lolaferrari,

serialband has given you 3 options.  What is wrong with the 3rd one of them?  You can put your 40 or 50 (or as many as you like) items in the exclude_list.txt file (or whatever filename you what to use).
0
 

Author Comment

by:lolaferrari
Comment Utility
Fantastic help! thank you
0
 
LVL 27

Expert Comment

by:serialband
Comment Utility
Ok, strange.  I though I responded to you @tel2.  In fact, I remember doing it twice, but I still don't see my response.


It's as you say.  I gave examples to help with the syntax, since I wasn't sure what @lolaferrari needed.

@lolaferrari
The 3rd option is best with a file with 40 or 50 items.  I can't think of anything that would improve on that.  The grep command placese everything into one grep process.  Anything else would spawn additional processes and slow it down more.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now