LinuxQuestions.org
Review your favorite Linux distribution.
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 12-01-2010, 08:55 AM   #1
josecolella
Member
 
Registered: Nov 2010
Location: Milan, Italy
Distribution: Linux Mint 13, Debian 6.0
Posts: 62

Rep: Reputation: 3
Question Having trouble with grep command


I'm trying to use grep to find the words in the dictionary that contain the letters "th" and the letter m.

I tried

grep 'th m*.' Desktop/Dictionary/words(Thats where the destined dictionary word document is located)

grep 'th' Desktop/Dictionary/words works but only for the words with th. I have no idea of what expression to use to make it a unionized expression with m
 
Old 12-01-2010, 09:13 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,808

Rep: Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604
http://www.regular-expressions.info/

m and th, in any order? Try "(th.*m|m.*th)". You'll need to use grep's -E switch to turn on extended regexes (or -P for PCRE).
 
1 members found this post helpful.
Old 12-01-2010, 09:27 AM   #3
BertM
LQ Newbie
 
Registered: Jan 2010
Location: Belgium
Distribution: Debian
Posts: 17

Rep: Reputation: 0
I was going to suggest

grep -E '.*(th|m).*(th|m).*' Desktop/Dictionary/Words

but AlucardZero's suggestion works fine.

The site he suggested is a really great source of information on regular expressions as well.
 
Old 12-01-2010, 05:04 PM   #4
josecolella
Member
 
Registered: Nov 2010
Location: Milan, Italy
Distribution: Linux Mint 13, Debian 6.0
Posts: 62

Original Poster
Rep: Reputation: 3
thank so much you were a great help and thanks for the website, i have bookmarked it because it contains a lot of vital information
 
  


Reply


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
Trouble with grep extended regez in for loop ineluki12 Linux - General 3 06-03-2010 04:58 PM
How to pass the result of a command to another command (like grep) desb01 Programming 4 06-25-2009 01:09 PM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 05:16 AM
trouble with grep command thodo Programming 3 08-19-2007 08:46 AM
cat [file] | grep --- trouble bob_man_uk Linux - General 12 03-10-2006 07:05 AM


All times are GMT -5. The time now is 01:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration