Class Notes (810,888)
Canada (494,323)
CS 246 (116)

cs246 lecture3-4 (spring 2014).pdf

6 Pages
Unlock Document

University of Waterloo
Computer Science
CS 246
Nomair Naeem

Lecture 3PipesLets you use the output of one program as the input as anotherSet the 2nd programs stdin to the 1st programs stdoutExample How many words occur in the rst 20 lines of sampletxthead n Display the rst n lines of lewc w Counts wordsSoln head 20 sampletxtwc wUse the input of rst command as the input of the second commandor cat sampletxthead 20wc wSuppose les words1txt and words2txt contain list of words one per line Print a duplicate free list of all the words that occur in any of the lessortsort a listuniqremove duplicates that are adjacentcat wordstxtsortuniqWe can also use the output of a program as a parameter to another programuse backquotesecho Today is date and I am whoamiecho Today is date and I am whoamiecho Today is date and I am whoamiPattern Matching inside Text FilesTool grep global regular expression printegrepextended grep grep EUsage egrep pattern leOutput Prints every line in le that contains patternExample Print every line in indexhtml that contains cs246egrep cs246 indexhtmlExample How many lines in indexhtml contain cs246egrep cs246 indexhtmlwc lWhat patterns can I use with egreq Anything that can be specied as a regular expressionExample search for cs246 or CS246egrep cs246CS246 indexhtmlegrep csCS246 indexhtmlegrep cCsS246 indexhtmlalso matches cS246 Cs246 egrep cCsS246 indexhtml matches any one of the characters betweenand abcdabcd matches anything except one of the characters
More Less

Related notes for CS 246

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.