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.
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.
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.
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 '^(<TH CLASS=“ddtitle”|<TD CLASS=“dddefault”>)'| 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.
variables (environment/local)
A local variable is only known in the function that you created it in. It isn't known in any other functions and can't be used in any other function. Each time you use the function is starts at whatever value you assigned it to. Global variables are known and can be used by any function in the program. So if you make a variable outside of main() it is a global variable because it can be used in any function. If you make a variable inside main() it can only be used in main() so it is a local variable.
Intersection
Two sets A and B is the set that contains all elements of A that also belong to B (or equivalently, all elements of B that also belong to A), but no other elements.
Example:
The intersection of the sets {1, 2, 3} and {2, 3, 4} is {2, 3}.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Demonstration of the indicated keyword.
Example:
The intersection of {1, 2, 5, 7} and {1, 5, 6, 7} is {1, 5} Intersection of {red, white, green, blue} and {green, yellow, blue, white} is {green, white, blue} Intersection of {1,5} and {1,5} is {1,5}
here string
The symbol for a here string is «< . A here string puts whatever input you want into a command. Like bc «< 2+2 sends 2+2 into the calculator and it will come back as 4. So it does the operation in one step instead of going into the calculator and typing 2+2 or whatever you want to solve.
* Notes from when we talked about here strings and the binary calculator.
variable expansion
Variable expansions are defined by lines using ':=' It does not contain any references to other variables; it contains their values as of the time this variable was defined.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Demonstration of the indicated keyword.
#include <stdio.h> int main() { int x = 20; printf("The value of x is %d\n", x); }
The output of this is The value of x is 20
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.
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.
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.
Im going to change the script from the puzzlebox a little and see if it does what I think it will.
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.
Based on the data collected:
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.