Unix/Linux Go Back    


Homework & Coursework Questions Students must use and complete the template provided. If you do not use the template your post may be deleted! Special homework rules apply here.

Student needs grep command help

Homework & Coursework Questions


Tags
grep, homework, student

Reply    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 11-24-2017   -   Original Discussion by jetoutant
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 24 April 2018, 1:13 AM EDT
Location: Aachen, Germany
Posts: 12,512
Thanks: 401
Thanked 3,879 Times in 3,566 Posts
Quote:
Originally Posted by jetoutant View Post
. . .


Code:
grep ECE 3\.[5-9] smallFile
grep 'ECE 3\.[5-9]' smallFile
grep ECE {3}\.[5-9] smallFile 
grep ECE '{3}\.[5-9]' smallFile

don't work to eliminate a 2or 4 before the dot
There's a fundamental difference between form 1, 3 and 4 and form 2 of your commands. Can you tell it?
Why shouldn't one form (which one?) work given you match the field separators in data file and regex?
Sponsored Links
    #9  
Old Unix and Linux 11-24-2017   -   Original Discussion by jetoutant
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is online now Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 26 April 2018, 1:35 AM EDT
Location: Simplicity
Posts: 4,043
Thanks: 346
Thanked 1,359 Times in 1,225 Posts
Put the grep expression in " " or ' ' quotes, otherwise even the shell tries substitutions.
Use bounds, at least "word boundary" anchors, better the field separator.
Sponsored Links
    #10  
Old Unix and Linux 11-24-2017   -   Original Discussion by jetoutant
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 25 April 2018, 11:59 PM EDT
Location: San Jose, CA, USA
Posts: 11,222
Thanks: 633
Thanked 3,905 Times in 3,343 Posts
Quote:
Originally Posted by jetoutant View Post
this worked



Code:
grep 3\.[5-9] smallFile | grep ECE

thanks for all the help it is much appreciated

now that I have been up about 20 trying to figure this out I can get some sleep now that I figure the 6 out next is shell script to be done when I wake up
Does that work if you use a BRE similar to that to look for a GPA greater than or equal to 3.00 and less than 3.50?

P.S.: How do you know the two digits and the decimal point you are matching are in the GPA field and not in the last field of your data?

Last edited by Don Cragun; 12-02-2017 at 11:53 PM.. Reason: Add postscript.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Student needs grep command assistance jetoutant UNIX for Beginners Questions & Answers 1 11-23-2017 03:50 PM
Hello Everyone - Student in Need of Help Hexum311 UNIX for Dummies Questions & Answers 1 04-07-2007 11:37 PM
student need help! willnadaze UNIX for Dummies Questions & Answers 6 12-05-2005 09:23 AM
Newbie Student Need Help! DaSFLiP Shell Programming and Scripting 0 04-04-2005 07:19 PM
Student needs help... MGold4357 Linux 4 04-09-2004 10:44 AM



All times are GMT -4. The time now is 01:59 AM.