LinuxQuestions.org
Visit Jeremy's Blog.
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-17-2009, 05:12 PM   #1
Bleek
LQ Newbie
 
Registered: Dec 2009
Posts: 11

Rep: Reputation: 0
Grep command problem~


Question
Display all of the lines in the file that contain "Raspberry" followed later in the line
by the letter "a".
File name = inventory

I have no idea how I could possibly do it so I'm wondering if someone with more experience might be able to enlighten me.
I've tried:
grep "Rasberry.*a" inventory
grep "Rasberry a" inventory
grep "Rasberry.* a" inventory
grep "Rasberry a" inventory
None of these work, the only file in 'inventory' that matches the description is 'Raspberry Jam,1216,194' so I'm hoping someone could help me ;x Thanks.
 
Old 12-17-2009, 05:23 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
This worked for my data file...

grep "Raspberry.*[a]" inventory

Regards
 
Old 12-17-2009, 05:25 PM   #3
harry edwards
Member
 
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
Try
Quote:
grep "Raspberry.*[a]" inventory
 
Old 12-17-2009, 05:26 PM   #4
harry edwards
Member
 
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
Grrr, someone beat me to it :-(
 
Old 12-17-2009, 05:29 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,848

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
Perhaps if you correctly spelt "Raspberry" ?.
 
Old 12-17-2009, 05:37 PM   #6
Bleek
LQ Newbie
 
Registered: Dec 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
Perhaps if you correctly spelt "Raspberry" ?.
Wow... uhm >.> Thank you good sir. I didn't sleep at all last night so these kind of things are slipping by me... Ya that was the issue, thanks everyone for your help, I'm retarded.
 
Old 12-17-2009, 08:31 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
And to mr Weaver and Edwards: using a character class for
an individual character is pointless. ;}
 
Old 12-18-2009, 10:49 AM   #8
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
I didn't test his previous examples, but earlier in the day I had done similar with a range *shrugs* I would tend to argue that it occasionally helps readability while not a functional addition.
 
  


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
How to pass the result of a command to another command (like grep) desb01 Programming 4 06-25-2009 01:09 PM
Problem with simple grep command jacksmash Linux - General 3 09-10-2008 06:01 PM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 05:16 AM
problem with grep command thodo Linux - Newbie 1 10-25-2007 05:20 AM
Simple grep command problem acis Linux - General 2 07-16-2004 01:21 PM


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