LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-08-2013, 08:41 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
grep -R --exclude=


Hi,

I want to grep a string assumed 'thomas2004' from all the files but exclude the *.log. I use a command as follow:
Code:
grep -R --exclude="*.log" thomas2004
But it seems it doesn't work.

Any idea?
 
Old 03-08-2013, 09:07 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Shouldn't that be:
Code:
grep -R --exclude="*.log" "thomas2004" *
 
1 members found this post helpful.
Old 03-09-2013, 10:09 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I suggest using '.' as the search path instead of '*'. The latter will be expanded by the shell into the full directory contents before execution. It may not make much overall difference, but it's best to be careful.

PS, while not particularly useful with "grep -R", in most other commands it's possible to use bash's extended globbing to exclude individual filenames from processing.
 
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
[SOLVED] grep for multiple strings to exclude greenpool Linux - General 7 12-05-2011 04:20 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 - Software

All times are GMT -5. The time now is 12:13 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