LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-17-2009, 04: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, 04:23 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

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

grep "Raspberry.*[a]" inventory

Regards
 
Old 12-17-2009, 04: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, 04: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, 04:29 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Perhaps if you correctly spelt "Raspberry" ?.
 
Old 12-17-2009, 04: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, 07:31 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

Rep: Reputation: 167Reputation: 167
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



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 12:09 PM
Problem with simple grep command jacksmash Linux - General 3 09-10-2008 05:01 PM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 04:16 AM
problem with grep command thodo Linux - Newbie 1 10-25-2007 04:20 AM
Simple grep command problem acis Linux - General 2 07-16-2004 12:21 PM

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

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