Today we went over the creation of a C script capable of calculating the average of 4 numbers entered by the user;
//10-17script #include<stdio.h> int main() { int a, b, c, d; float e; fprintf(stdout, "Please enter nubmer 1: "); fscanf(stdin, "%d", &a); fprintf(stdout, "Please enter number 2: "); fscanf(stdin, "%d", &b); fprintf(stdout, "Please enter number 3: "); fscanf(stdin, "%d", &c); fprintf(stdout, "Please enter number 4: "); fscanf(stdin, "%d", &d); e=(float)(a+b+c+d)/4; fprintf(stdout, "The average is %f/n", e); return(0); }
Today was dedicated to the explanation and manipulation of processes, including the 64 kill options. The SIG commands, used to kill processes, that we covered in class include; -1-SIGHUP (1st kill option) -2-SIGINT -3-SIGQUIT (sent every time 'x' button is clicked) -4-SIGILL (kills illegal functions) -9-SIGTERM (default kill, terminate) -15-SIGKILL (unavoidable kill)
Today we covered the use of 'grrasp:~$', including the use of flakes to send files to other computers. examples.) echo $Display =output environment who =output all environments xeyes -display flake01:5 =send x program 'eyes' to flake01:5 pkill xeyes =kills all xeyes you initialize xwininfo -root -display =screen details xhost minus =blocks new things from screen
Today we covered the following commands and their uses in class; -last = logins from now till start of month. -head = read the first part of a file -tail = output the last part of a file -paste = merge lines of files -comm = compare two sorted files line by line (show similarities) -diff = compare files line by line (shows differences) -join =join lines of two files to a common field.
diff/diff3/patch
Operations used to compare files, outputting their differences, and is often used to tell the differences between versions of the same file.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
sort/uniq
The sort commands sorts the the lines of text files in order. You can use different arguments like -r to sort them in reverse order. The uniq command is used with the sort command to remove duplicate lines in the file that you are sorting. There are also arguments for uniq like -d that only prints duplicated lines or -u that only prints unique lines.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Demonstration of the indicated keyword.
If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:
Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows: SORT:
lab46:~/src/class$ vim testdata 'testdata' 1 alpha 2 beta 3 zeta 4 kapa 5 kapa 6 sigma 7 sigma 8 foxtrot 9 foxtrot 10 delta 11 hotel lab46:~/src/class$ sort -d testdata alpha beta delta foxtrot foxtrot hotel kapa kapa sigma sigma zeta
UNIQ:
lab46:~/src/class$ vim testdata 'testdata' 1 alpha 2 beta 3 zeta 4 kapa 5 kapa 6 sigma 7 sigma 8 foxtrot 9 foxtrot 10 delta 11 hotel lab46:~/src/class$ uniq -d testdata kapa sigma foxtrot
What is the question you'd like to pose for experimentation? State it here.
Is there a way you can find out if a pattern occurs in something consecutively, and in reverse. It seems like a complex process so I'm curious.
Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.
It turns out that after some research, the thing I was curious about is defined as a palindrome, it is a string of letters or numbers that reads one way the same as it does the other.
(http://en.wikipedia.org/wiki/Palindrome) (http://www.fun-with-words.com/palin_explain.html)
Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.
State your rationale.
Based off of what I have read, and learned from other people, I believe it is more than possible to make a script that does what I'd like, as it seems there are many that already exist that do such a thing.
How are you going to test your hypothesis? What is the structure of your experiment?
I will construct a script which i will then change into an executable file, I will then feed it strings of text to see if it can correctly distinguish between palindromes and non-palindromes.
Perform your experiment, and collect/document the results here.
1 #script: exp3 2 #this is to test strings for palindrome characteristics 3 echo "String please :" 4 read str 5 len=`expr $str | wc -c` 6 len=`expr $len - 1` 7 mid=`expr $len / 2` 8 flag=1 9 m=1 10 while [ $m -le $mid ] 11 do 12 c=`echo $str | cut -c$len` 13 p=`echo $str | cut -c$m` 14 if [ $c != $p ] 15 then 16 flag=0 17 break 18 fi 19 m=`expr $m + 1` 20 len=`expr $len - 1` 21 done 22 if [ $flag -eq 1 ]
lab46:~/src/Unix/submit/Opus$ ./exp3 String please : cat The string is not palindrome lab46:~/src/Unix/submit/Opus$ ./exp3 String please : boob The string is palindrome lab46:~/src/Unix/submit/Opus$
Based on the data collected:
-Yes
-No, it was.
-Yes, the logic is much more involved and the script much more complex than I would have originally guessed.
-Lack of personal knowledge prior to the planning of the experiment.
-Only two words were tested so as not to present irrelevant data past testing the script's functionality.
What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.