How to Submit
Week 4REQUIRED READING: The story of Unix. If you only read one thing in this independent study, it should be this. It is a terrific story. And it should make you feel the connection between the work you're doing in this class and the larger technological revolution that defines your generation. Unfortunately, I can't find a nice single-document version. You'll have to read it on the web: http://www.bell-labs.com/history/unix/ ex1: Unix exploration adventure What does this do? %> echo "Baker Is Awesome" | tr " " "\n" | sort Here's how to figure it out: - Run the command repeatedly, each time removing a piece of the pipeline. - Remove some of the options arguments from the command so you can see what they do. - Read the man page for each command, so that you understand the options used. You are encouraged to play with various options that are used to make the output look a little bit different. Now, how about this one: %> echo "Baker Is Awesome and the coolest Baker in the World" | tr " " "\n" | sort | uniq Now, here is a long unix command pipeline. Run it (you can hit <enter> or <space> to advance the page: %> ls -lh /etc/ | tr -s " " ":" | cut -f9,5 -d: | tr ":" "\t" | nl | pr -2 -w80 -l20 | more Now modify the options for ls so that this prints out in order of file size from smallest to largest. Why do you have to change the options on ls? Why won't piping to sort work? WHAT TO TURN IN for ex1: Explain, in English, what the last pipelined command does. Also, copy and paste your command that sorts the files from smallest to largest. ex2: How could you quickly determine how many times the word "independent" (without regard for capitalization) appears in the Declaration of Independence? Here is a link to the file: decl.txt Write a one-line unix pipeline that will print the numerical result. You may find the "wc" command helpful, as well as "grep." I'll let you read the man page on wc yourself. Grep is actually a very simple command that can do very complex things. For purposes of this exercise, you only need to know that grep will locate a given string within any line of text. It will print out any lines of text that contain the string you're looking for. EXAMPLE: Say you have a file, called text.txt with the following contents: ------------- Baker is Awesome and the coolest Baker in the World. -------------- If you enter the following command, you will get the result shown: %> cat text.txt | grep "Baker" Baker is Awesome the coolest Baker in the Be careful though. Something can match twice in one line. For example: %> cat text.txt | grep "the" the coolest Baker in the So, 'the' appears twice, but on one line. What to turn in for ex2: Produce a transcript of you using the one-line command you came up with, that shows the results.