======Part 2====== =====Entries===== ====Entry 1: October 17, 2012==== Today we talked about the ps and top command. The ps command shows all the processes I'm running on the terminal. The ps a command shows all the processes associated with the terminal. We also talked about the top command which shows all the top running processes on the system. I found out that there is 15 ways to kill things in linux. I forget which one we don't want to do very often. I think it might be number 9 but they all pretty much do the same thing with just a few little differences. We also made a small c program that finds the average of 4 numbers using printf and scanf. We then made another c program that does the same thing just using fprintf and fscanf. With fprintf and fscanf you have to put stdout or stdin. ====Entry 1: October 24, 2012==== Today we went over regular expressions. We talked about the different kinds of regular expressions we could use to find the data that we want. The ^ matches the beginning of a line, the $ matches the end of line, the \< matches the beginning of the line, \> matches the end of the word, . matches any single character, * 0 is 0 or more of the previous character or whatever you put in front of the *, [] matches any of the characters enclosed, [^ ] ddoes not match any of the characters enclosed. Then there is also extended regular characters or egrep. Those are () which is like \( \), | which means or and + which matches 1 or more of the previous character. After we got done talking about and experimenting with regular expressions a few of us still had to finish the puzzlebox 2. The puzzlebox took a little but I finished it a few minutes after class was over. ====Entry 2: October 25, 2012==== Today we worked on the set program 2 as well as just worked on anything that we needed to work on. I looked at the set program for a little while until I got a little frustrated so I decided to have a little break. I started working on the entries for days since I haven't started any and its almost the end of the month. After I get done doing this entry I'll probably start looking at examples that I haven't done yet. Maybe I won't wait until the very last day this month. ====Entry 4: October 31, 2012==== Today we went over the spring 2013-20121026.html and tried to change it so that we could look up the type of classes that we want. We started talking about it for the first half of class and got a good start on it. About half way through class we started trying to figure it out on our own. Started experimenting with the sed command and got it to look a little better than it did before with all the default classes tag and a few other little changes like that. I ended the class with this command cat spring2013-20121026.html | egrep '^()'| sed 's/< */ /g' | sed 's/> */ /g' | sed 's/TD CLASS="dddefault" */ /g' | sed 's/TD */ /g' | grep -A 8 MATH The last part I needed help figuring it out. =====Keywords===== {{page>discretepart2&nofooter}} {{page>unixpart2&nofooter}} =====Experiment 2===== ====Question==== In the script from puzzlebox 2 Im wondering if I replace tail with head if it would do the same thing. I think it will as long as I move my username to the top. ====Resources==== The man page and wikipedia page on the head command says that it prints out the first 10 lines unless you specify how many lines you want it to print out. Thats pretty much what I thought it would do. http://ss64.com/bash/head.html ====Hypothesis==== I think that the script will do the same thing with the head command as it did with the tail command. Since the tail command looks at the last line with the -1 argument I'm guessing the head command with the -1 will do the opposite and look at the first line. The man page and wikipedia page seem to say that I'm going to be right. ====Experiment==== Im going to change the script from the puzzlebox a little and see if it does what I think it will. ====Data==== It seems that my hypothesis was right. I still got the token at the end of the script. I changed the tail -1 to head -5 and ran it using the same symbolic link. Hopefully the symbolic link wasn't why I still got the token. ====Analysis==== Based on the data collected: * My hypothesis was kind of correct. Since Im pretty sure the #!/bin/bash line has to be first I ended up putting the username line on the 5th line and changing the -1 to -5. * I don't think there was any shortcomings in my experiment I still got the token. I switched the tail -1 command to a head -5 and moved the last line to the end of the comments at the top. * If I had to make a new symbolic link my experiment was probably not updated but I don't think I would have to do that. ====Conclusions==== I found out that the head command and the tail command work in about the same way just the tail looks at the bottom and the head command looks at the top. I still got the token at the end of the script. As long as you know how many lines you want it to look at than it will do the same thing. I almost messed up and put the username line before the #!/bin/bash line but realized it before I did it.