LinuxQuestions.org
Visit Jeremy's Blog.
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 04-14-2016, 03:50 AM   #1
akthomas1
LQ Newbie
 
Registered: Apr 2016
Location: Bangalore
Posts: 1

Rep: Reputation: Disabled
How to exclude a particular directory from being searched while using grep function


How to exclude a particular directory from being searched while using grep function,like for example I want to grep for a pattern "abc" in a directory called main but I don't want to search for "abc" in one of the sub directories,say sub of main.So how to exclude sub from being grepped?
 
Old 04-14-2016, 04:10 AM   #2
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
have you tried consulting "man grep"

it has this options:

--exclude, and --exclude-dir

Like:

grep -r "Search_this_dir" /path/to/be/search --exclude-dir="do_not_include_this_dir"


BTW, Welcome to LQ!!

Cheers..happy learning.

Last edited by JJJCR; 04-14-2016 at 04:22 AM. Reason: edit
 
1 members found this post helpful.
  


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
grep -R --exclude= thomas2004ch Linux - Software 2 03-09-2013 10:09 AM
[SOLVED] Can grep exclude symlinks ?? JamesEarlOwens Linux - Newbie 10 10-21-2011 04:05 AM
Using find and grep - how to exclude a result ? graziano1968 Linux - General 13 12-04-2010 10:02 PM
[SOLVED] grep exclude Manuel-H Linux - General 4 10-12-2010 08:50 PM
Exclude certain patterns from grep? kinetik Linux - General 4 04-24-2006 05:37 AM

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

All times are GMT -5. The time now is 01:04 AM.

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