Unix/Linux Go Back    


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

Grep commands: need some practice help please

Homework & Coursework Questions


Tags
grep

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 3 Weeks Ago
asaint asaint is offline
Registered User
 
Join Date: Jun 2017
Last Activity: 5 June 2017, 9:02 AM EDT
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Grep commands: need some practice help please

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Use the less command to view the words file.
To see the results of a grep that returns many rows, pipe the output of the grep into less. For example, grep ‘the’ words | less

You can pipe the output of a grep command into wc -l to count lines instead of displaying them.
How many words in this file begin with the letter x?
How many words in this file begin with the letter z?
How many words in this file begin with the letter x or z?

find or count the words in dictionary that:
end in ing (such as counting)
include ing but not at the end (such as ringing)
begin with a capital letter
contain only two letters, the first is lower case, the second uppercase (such as kW)
contain only the letters in simon in any order (such as osmosis)
begin with a vowel (aeiou)
do not contain a vowel (such as rhythm)
contain four consecutive vowels (such as queue)
are there any words with 5 consecutive vowels?
can be spelled using the 7 hex letters (such as faced)
contain all five vowels in the correct order a,e,i,o,u




2. Relevant commands, code, scripts, algorithms:
grep, less,pipes,egrep


3. The attempts at a solution (include all code and scripts):


not sure how to do any of these



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
UCOL Palmerston North, New zealand, Simon Burt, T111

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
Sponsored Links
    #2  
Old Unix and Linux 3 Weeks Ago
Neo's Unix or Linux Image
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 27 June 2017, 1:32 AM EDT
Location: Asia pacific region
Posts: 13,581
Thanks: 850
Thanked 1,139 Times in 533 Posts
Examples to think about. Try these command line experiments on your computer and see what happens:

echo Raining | grep ^R

What did you get after this experiment?

echo Raining | grep ^a

What did you get after this experiment?

echo Raining | grep ing$

What did you get after this experiment?

echo Raining | grep in$

What did you get after this experiment?

Read the manual page on grep by trying this on your computer:

man grep

What did you see after you did the experiment above?

Did you see any information that might help you with your homework tasks?

Did you see any examples at the end of the manual entry that might help you?
The Following User Says Thank You to Neo For This Useful Post:
asaint (3 Weeks Ago)
Sponsored Links
    #3  
Old Unix and Linux 3 Weeks Ago
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 27 June 2017, 5:24 AM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 5,449
Thanks: 100
Thanked 1,510 Times in 1,120 Posts
Quote:
Originally Posted by asaint View Post
You can pipe the output of a grep command into wc -l to count lines instead of displaying them.
You are perhaps not supposed to know that, but to show you that it pays off to come to unix.com for advice, here is how you might earn bonus points:

There is a way you can do that (counting that is) without using wc -l. You can find out how by carefully reading the man page of grep as Neo suggested.

You might also want to read this to get you started.

I hope this helps.

bakunin

Last edited by bakunin; 3 Weeks Ago at 07:12 AM..
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
Help with ls, grep commands kraljic Shell Programming and Scripting 7 04-13-2014 10:41 PM
Grep Commands smkremer Shell Programming and Scripting 2 08-28-2013 01:36 PM
How to practice unix commands on windows 7 machine tester213 UNIX Desktop Questions & Answers 4 05-18-2012 03:37 PM
How to run UNIX commands for practice in Windows 2000 OS? Srikanthk UNIX for Dummies Questions & Answers 2 02-20-2009 09:16 AM
Simple grep question, but I'm out of practice citygov Shell Programming and Scripting 0 08-02-2005 10:31 AM



All times are GMT -4. The time now is 06:19 AM.