 | Junior Member with 7 posts. | | | | simple grep command Here is a question that I could not figure out how to do:
Display a list of all of the lines in the file that contain "Compote" or
"compote"
Strawberry Jam,300,191
Raspberry Jam,1216,194
Blueberry Jam,96,195
Strawberry Compote,49,621
Raspberry Compote,1937,624
Blueberry compote,200,625
Frozen Strawberries,130,1941
Straw Hats,16,2047
This is basically a simple grep command. However, I cannot use the grep -i option, which is really frustrating.
Anyone know a solution? | | Senior Member with 1,513 posts. | | Join Date: Jul 2005 Experience: I've been at this for too long. | | grep -e "[cC]ompote" filename | | Distinguished Member with 14,983 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | Quote: |
Originally Posted by jiml8 grep -e "[cC]ompote" filename | That is probably the easiest way or you can put all your search terms in a file and use the -f option. | | Junior Member with 7 posts. | | | | the command worked, thanks. Although the -e extension was nescessary. One last question though...
Display all of the lines in the file that contain "Raspberry" followed later
in the line by the letter "a".
I believe that this question uses the wildcard, but I'm not sure how to follow up with the letter "a" | | Distinguished Member with 14,983 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | | | | Junior Member with 7 posts. | | | | Quote: |
Originally Posted by Squashman Raspberry*a | Thank you for your help sir, that was not quite correct. The answer was...
grep "Raspberry.*a" inventory
anyways...the final question is:
Display all of the lines in the file where the last field is 4 digits long.
Search for "," before the field to make sure your regular expression matches
the whole field, use character classes to match four digits, and anchor it
to the end of the line to make sure it's the last field.
Anyone know this? | | Senior Member with 1,513 posts. | | Join Date: Jul 2005 Experience: I've been at this for too long. | | Quote: |
Originally Posted by netmaster Thank you for your help sir, that was not quite correct. The answer was...
grep "Raspberry.*a" inventory
anyways...the final question is:
Display all of the lines in the file where the last field is 4 digits long.
Search for "," before the field to make sure your regular expression matches
the whole field, use character classes to match four digits, and anchor it
to the end of the line to make sure it's the last field.
Anyone know this? | Are we doing your homework for you? I think you need to figure this one out for yourself (I have the answer here but it sure looks like you are supposed to be doing this). | | Junior Member with 7 posts. | | | | Actually they are exam practice questions, not homework. Everything is complete at this point. Thanks for everyones help. | | Distinguished Member with 14,983 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | Quote: |
Originally Posted by netmaster Thank you for your help sir, that was not quite correct. The answer was...
grep "Raspberry.*a" inventory
| It was correct for what you were asking. | | Senior Member with 130 posts. | | |
08-Dec-2005, 01:05 AM
#10 | Quote: |
Originally Posted by netmaster Here is a question that I could not figure out how to do:
Display a list of all of the lines in the file that contain "Compote" or
"compote"
Strawberry Jam,300,191
Raspberry Jam,1216,194
Blueberry Jam,96,195
Strawberry Compote,49,621
Raspberry Compote,1937,624
Blueberry compote,200,625
Frozen Strawberries,130,1941
Straw Hats,16,2047
This is basically a simple grep command. However, I cannot use the grep -i option, which is really frustrating.
Anyone know a solution? | If i did not read the question wrongly, it says just display the lines where
there is either 'Compote' or 'compote' right?
grep -i compote can definitely list them out. Does your "grep" have the -i option? |  THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.
|
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 03:37 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|