Help answer threads with 0 replies.
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 08-07-2012, 01:59 AM   #1
LQ Newbie
Registered: Jul 2010
Posts: 18

Rep: Reputation: 0
shell script to search a pattern in a diretory and output number of find counts

I need a Shell script which take two inputs which are
1) main directory where it has to search and
2) pattern to search within main directory all files (.c and .h files)
It has to print number of pattern found in main directory & each sub directory.
main dir --> Total pattern found = 5
sub dir --> 3
sub dir --> 2
Old 08-07-2012, 02:14 AM   #2
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297

You'll have a hard time finding someone here on LQ that will do your work for you. Show us what you've got and where it's failing and we'll point you in the right direction. Good starting points are:
Bash Guide for Beginners
Advanced Bash Scripting Guide

Kind regards,



pattern, search, shell script

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] How to search file by pattern and then delete corresponding lines in shell cyatomato Programming 8 09-17-2010 09:08 AM
Pattern search question in shell shogun1234 Linux - Newbie 10 10-10-2009 10:17 AM
how to find given number is integer or not in shell script kvmreddy Linux - Newbie 2 08-15-2009 09:05 AM
how to find a pattern using shell script sharad Linux - General 1 05-23-2006 04:50 AM
pattern search through find command. abhi Linux - Newbie 2 04-11-2005 11:31 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:49 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
Open Source Consulting | Domain Registration