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 - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-05-2016, 03:48 AM   #1
Vthimmap
Member
 
Registered: Oct 2012
Posts: 36

Rep: Reputation: Disabled
Question print the number of occurrence of a pattern in multiple files count greater than 10


Have output in the below format.
The paterrn(HeartBeat) is searched in file of multiple directories.
Now wanted to print the files which has many occurrence of the pattern. if the pattern count crosses 10, let it print the file , otherwise not

egrep -i -c "HeartBeat" /export/acdba/ac/data/workdir/batch/*20160705*/jobdef.log

/export/acdba/ac/data/workdir/batch/dir1/jobdef.log:2
/export/acdba/ac/data/workdir/batch/dir2/jobdef.log:1
/export/acdba/ac/data/workdir/batch/dir3/jobdef.log:1
/export/acdba/ac/data/workdir/batch/dir4/jobdef.log:1
/export/acdba/ac/data/workdir/batch/dir5/jobdef.log:46
/export/acdba/ac/data/workdir/batch/dir6/jobdef.log:8
/export/acdba/ac/data/workdir/batch/dir7/jobdef.log:19
/export/acdba/ac/data/workdir/batch/dir8/jobdef.log:2
/export/acdba/ac/data/workdir/batch/dir9/jobdef.log:5
/export/acdba/ac/data/workdir/batch/dir10/jobdef.log:1
/export/acdba/ac/data/workdir/batch/dir11/jobdef.log:1
/export/acdba/ac/data/workdir/batch/dir12/jobdef.log:1
/export/acdba/ac/data/workdir/batch/dir13/jobdef.log:3
/export/acdba/ac/data/workdir/batch/dir14/jobdef.log:1
/export/acdba/ac/data/workdir/batch/dir15/jobdef.log:24
 
Old 07-05-2016, 04:49 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
so you need to filter the result
I would suggest you to use awk, use : as field separator
 
Old 07-05-2016, 10:33 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Or you could feed it to a while loop ... really the options are pretty endless
 
Old 07-05-2016, 10:44 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Quote:
Originally Posted by Vthimmap View Post
Have output in the below format.
The paterrn(HeartBeat) is searched in file of multiple directories.
Now wanted to print the files which has many occurrence of the pattern. if the pattern count crosses 10, let it print the file , otherwise not
Print the whole file? to standart output, on paper?
 
Old 07-05-2016, 09:28 PM   #5
Vthimmap
Member
 
Registered: Oct 2012
Posts: 36

Original Poster
Rep: Reputation: Disabled
to standard output
 
Old 07-05-2016, 09:28 PM   #6
Vthimmap
Member
 
Registered: Oct 2012
Posts: 36

Original Poster
Rep: Reputation: Disabled
just the file names
 
Old 07-06-2016, 03:05 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
I have to say, I am a little curious at the example output based on your grep statement. You have *20160705* in the path but your output has dirN at he same point in the path?

Don't forget to show us what you have tried and we will help where you are stuck?
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] move files on the basis of date range/name pattern and head count sunny singhal Linux - Newbie 7 02-09-2016 02:19 PM
[SOLVED] Count occurrence of character in field and print in a new field Trd300 Linux - Newbie 5 03-21-2012 07:57 PM
multiple pattern search and count the no. of occurances raghu123 Programming 4 06-03-2009 04:50 PM
Replace every other occurrence of pattern Wynd Linux - General 8 12-14-2005 03:43 PM
count total number of lines in several files xushi Programming 5 11-12-2005 04:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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