LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grep command problem~ (https://www.linuxquestions.org/questions/linux-newbie-8/grep-command-problem%7E-776525/)

Bleek 12-17-2009 04:12 PM

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.

rweaver 12-17-2009 04:23 PM

This worked for my data file...

grep "Raspberry.*[a]" inventory

Regards

harry edwards 12-17-2009 04:25 PM

Try
Quote:

grep "Raspberry.*[a]" inventory

harry edwards 12-17-2009 04:26 PM

Grrr, someone beat me to it :-(

syg00 12-17-2009 04:29 PM

Perhaps if you correctly spelt "Raspberry" ?.

Bleek 12-17-2009 04:37 PM

Quote:

Originally Posted by syg00 (Post 3795924)
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.

Tinkster 12-17-2009 07:31 PM

And to mr Weaver and Edwards: using a character class for
an individual character is pointless. ;}

rweaver 12-18-2009 09:49 AM

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.


All times are GMT -5. The time now is 11:43 PM.