User Tools

Site Tools


opus:fall2013:jvanzil4:start

Jon VanZile's fall 2013 Opus

Version 2.0! Now with more 'Splosions!

OPTIONAL SUBTITLE WILL REMAIN OPTIONAL

Introduction

My name is Jon. I lived as a vagrant after my parents were slain. As a disgusting vagrant, I drifted from town to town, begging and stealing. Eventually I decided that life was not worth living and formulated a plan to take my own life. As through an act of divinity; I was struck by an asteroid infused with mystical energies, energies that also stuffed tons of cash into my pockets. It was also around this time that I had learned that my parent's murderer had fled into a different dimension and began selling Microsoft Office products to spectral beings. He had taken this job as a way to make ends meet, I guess the economy was rough. I vowed, then and there, to use my new mystical energies to get a crappy low level job at Microsoft so that I may destroy the corporation from within. In so doing, I will rob my sworn enemy of his livelihood, forcing him to probably be late on his rent. Eventually, maybe he will be evicted from his apartment. If this happens, I will consider the death of my parents to be avenged. Also, there will be some hot chicks in the title sequence to illustrate that I'm some kind of bad ass dude.

Data Structures Journal

August, 28 2013

Today began the semester for Data Structures.

August, 29 2013

Today, we played around with pointers in order to describe pointers various effects on memory.

#include <stdio.h>
#include <stdlib.h>

int main()
{

int a, *b;

a=12;
b=&a;

fprintf(stdout, "[a] address is : 0x%X\n", &a);
fprintf(stdout, "[a] contains: %d\n", a);
//fprintf(stdout, "[a] dereferences to: %d\n",*a);
fprintf(stdout, "[b] address is : 0x%X\n", &b);
fprintf(stdout, "[b] contains: 0x%X\n", b);
fprintf(stdout, "[b] dereferences to: %d\n", *b);

a=137;

fprintf(stdout, "[a] address is : 0x%X\n", &a);
fprintf(stdout, "[a] contains: %d\n", a);
//fprintf(stdout, "[a] dereferences to: %d\n",*a);
fprintf(stdout, "[b] address is : 0x%X\n", &b);
fprintf(stdout, "[b] contains: 0x%X\n", b);
fprintf(stdout, "[b] dereferences to: %d\n", *b);

*b=2600;

fprintf(stdout, "[a] address is : 0x%X\n", &a);
fprintf(stdout, "[a] contains: %d\n", a);
//fprintf(stdout, "[a] dereferences to: %d\n",*a);
fprintf(stdout, "[b] address is : 0x%X\n", &b);
fprintf(stdout, "[b] contains: 0x%X\n", b);
fprintf(stdout, "[b] dereferences to: %d\n", *b);

return (0);
}

The result of compiling and running this program gives us the following:

the first segment:

[a] address is : 0x9834985C
[a] contains: 12
[b] address is : 0x98349850
[b] contains: 0x9834985C
[b] dereferences to: 12

the second segment:

[a] address is : 0x9834985C
[a] contains: 137
[b] address is : 0x98349850
[b] contains: 0x9834985C
[b] dereferences to: 137

the third segment:

[a] address is : 0x9834985C
[a] contains: 2600
[b] address is : 0x98349850
[b] contains: 0x9834985C
[b] dereferences to: 2600

This example is perhaps the most surprising. We can see here that 'a' now has the value of 2600; the very same value as directly associated with *b. This works because *b points to the address of a.

August 30, 2013

Today we created a program that would list the size in bytes, as well as the maximum and minimum values of various data types. This is useful because depending on the system you are using, this could change.

The code is as follow:

#include <stdio.h>
#include <stdlib.h>

int main(){

signed char sc =0;
unsigned char uc =0;
signed short int ssi =0;
unsigned short int usi =0;
signed int si =0;
unsigned int ui=0;
signed long int sli =0;
unsigned long int uli =0;
signed long long int slli =0;
unsigned long long int ulli =0;


fprintf(stdout, "A signed char is : %hhu bytes\n", sizeof(sc));
fprintf(stdout, "Lower bound is : %hhd\n", ((unsigned char)(sc -1)/2)+1);
fprintf(stdout, "Upper bound is : %hhd\n", ((unsigned char)(sc -1)/2));
fprintf(stdout, "-----\n");

fprintf(stdout, "An unsigned char is %hhu bytes\n", sizeof(uc));
fprintf(stdout, "Lower bound is : %hhu\n", uc);
fprintf(stdout, "Upper bound is: %hhu\n", uc-1);
fprintf(stdout, "-----\n");

fprintf(stdout, "A signed short int is : %hd bytes\n", sizeof(ssi));
fprintf(stdout, "Lower bound is : %hd\n", ((unsigned short int)(ssi -1)/2)+1);
fprintf(stdout, "Upper bound is : %hd\n", ((unsigned short int)(ssi -1)/2));
fprintf(stdout, "-----\n");

fprintf(stdout, "An unsigned short int is : %hu bytes\n", sizeof(usi));
fprintf(stdout, "Lower bound is : %hu\n", usi);
fprintf(stdout, "Upper bound is : %hu\n", usi-1);
fprintf(stdout, "-----\n");

fprintf(stdout, "A signed int is : %d bytes\n", sizeof(si));
fprintf(stdout, "Lower bound is : %d\n", ((unsigned int)(si -1)/2)+1);
fprintf(stdout, "Upper bound is : %d\n", ((unsigned int)(si -1)/2));
fprintf(stdout, "-----\n");

fprintf(stdout, "An unsigned int is : %u bytes\n", sizeof(ui));
fprintf(stdout, "Lower bound is : %u\n", ui);
fprintf(stdout, "Upper bound is : %u\n", ui-1);
fprintf(stdout, "-----\n");

fprintf(stdout, "A signed long int is : %ld bytes\n", sizeof(sli));
fprintf(stdout, "Lower bound is : %ld\n", ((unsigned long int)(sli -1)/2)+1);
fprintf(stdout, "Upper bound is : %ld\n", ((unsigned long int)(sli -1)/2));
fprintf(stdout, "-----\n");

fprintf(stdout, "An unsigned long int is : %lu bytes\n", sizeof(uli));
fprintf(stdout, "Lower bound is : %lu\n", uli);
fprintf(stdout, "Upper bound is : %lu\n", uli-1);
fprintf(stdout, "-----\n");

fprintf(stdout, "A signed long long int is : %lld bytes\n", sizeof(slli));
fprintf(stdout, "Lower bound is %lld\n", ((unsigned long long int)(slli -1)/2)+1);
fprintf(stdout, "Upper bound is %lld\n", ((unsigned long long int)(slli -1)/2));
fprintf(stdout, "-----\n");

fprintf(stdout, "An unsigned long long int : %llu bytes\n", sizeof(ulli));
fprintf(stdout, "Lower bound is %llu\n", ulli);
fprintf(stdout, "Upper bound is %llu\n", ulli -1);
fprintf(stdout, "-----\n");
return(0);
}

We can determine the size of a data type by using 'sizeof'

September 4, 2013

We began our journey into linked lists today. The definition of a linked list is essentially a data structure consisting of nodes. Where in each node contains a value and a “link” to the next node in the sequence.

The code to create a linked list n nodes long is as follows:

struct node{
        int value;
        struct node *next;
        };
typedef struct node Node;

int main(){

int input=0;
Node *list, *temp;
list=temp=NULL;

while(input!=-1){
        printf("Enter a value (-1 to end): ");
        scanf("%d", &input);
        if(input != -1){
                if(list == NULL){
                        list=temp=(Node*)malloc(sizeof(Node));
                        temp-> next=NULL;
                        list-> value=input;
                }
                else{
                        temp->next=(Node*)malloc(sizeof(Node));
                        temp->next->next=NULL;
                        temp->next->value=input;
                        temp=temp->next;
                }
        }
}
temp=list;

while(temp!=NULL){
        printf("%d->", temp->value);
        temp=temp->next;
        }
printf("NULL\n");
return(0);
}

When this code is compiled and ran, the user will be asked to input a value. As long as the user does not utilize -1 as the input, this will loop indefinitely. Every time the user enters a value, this value will be attributed to a newly created node. Once -1 is used as input, this loop ends and begins displaying the list.

September 5, 2013

Continuing our work with linked lists. We have derived the code to insert a node before a specified node, The code for which is as follows:

printf("Which node would you like to insert before? ");
scanf("%d", &input);
temp=list; 
for(seeker=0;seeker<(input-1);seeker++){
        temp=temp->next;
        }
printf("Enter a value to insert: ");
scanf("%d", &input);
temp2=(Node*)malloc(sizeof(Node));
temp2->value=input;
temp2->next=temp->next;
temp->next=temp2;

September 13, 2013

We have constructed a working linkedlist that will build a list, display the list, insert a node into the list, append a node into the list, and remove a node from the list. The code for this is as follow. it's hefty.

#include<stdio.h>
#include<stdlib.h>

struct node{
        int value;
        struct node *next;
        };
typedef struct node Node;

int main(){

int seeker, append, remove;
int input=0;
Node *list, *temp, *temp2, *temp3;
list=temp=temp2=temp3=NULL;

//Creates linked list
while(input!=-1){
        printf("Enter a value (-1 to end): ");
        scanf("%d", &input);
        if(input != -1){
                if(list == NULL){
                        list=temp=(Node*)malloc(sizeof(Node));
                        temp-> next=NULL;
                        list-> value=input;
                }
                else{
                        temp->next=(Node*)malloc(sizeof(Node));
                        temp->next->next=NULL;
                        temp->next->value=input;
                        temp=temp->next;
                }
        }
}

//Display linked list
temp=list;
input=0;
while(temp!=NULL){
        printf("[%d](%d)-> ",input, temp->value);
        temp=temp->next;
        input=input+1;
        }
printf("NULL\n");
//insert new node into list
printf("Which node would you like to insert before? :");
scanf("%d", &input);
temp=list; 
for(seeker=0;seeker<(input-1);seeker++){
        temp=temp->next;
        }
if(input==0){
        printf("Enter value to insert: ");
        scanf("%d", &input);
        printf("\n");
        temp2=(Node*)malloc(sizeof(Node));
        temp2->value=input;
        temp2->next=NULL;
        temp2->next=temp;
        list=temp2;
        }
        else{
                printf("Enter a value to insert: ");
                scanf("%d", &input);
                printf("\n");
                temp2=(Node*)malloc(sizeof(Node));
                temp2->value=input;
                temp2->next=temp->next;
                temp->next=temp2;
                }

//Displays linked list
temp=list;
input=0;
while(temp !=NULL){
        printf("[%d](%d)-> ",input, temp->value);
        temp=temp->next;
        input=input+1;
        }
printf("NULL\n");
printf("\n");

//Append after specified node
printf("Which node would you like to append? :");
scanf("%d", &input);
temp=list;
for(append=0;append<(input);append++){
        temp=temp->next;
        }
printf("Enter a value to append :");
scanf("%d", &input);
printf("\n");
temp3=(Node*)malloc(sizeof(Node));
temp3->value=input;
temp3->next=temp->next;
temp->next=temp3;

//Displays linked list
temp=list;
input=0;
while(temp !=NULL){
        printf("[%d](%d)-> ", input, temp->value);
        temp=temp->next;
        input=input+1;
        }
printf("NULL\n");

//Remove Node
temp=list;
printf("Which node would you like to remove? :");
scanf("%d", &input);
printf("\n");
for(remove=0;remove<(input-1);remove++){
        temp=temp->next;
        }
if (input==0){
        temp2=temp->next;
        temp->next=NULL;
        list=temp2;
        }
        else{
                temp2=temp->next;
                temp->next=temp2->next;
                temp2->next=NULL;
                }
//Displays linked list
temp=list;
input=0;
while(temp != NULL){
        printf("[%d](%d)-> ", input, temp->value);
        temp=temp->next;
        input=input+1;
        }
printf("NULL\n");
return(0);
}

This runs through in a continuous fashion. The code to display the list is inserted between every list operation, such as appending and removing. This is certainly inefficient and we have been tasked with creating a menu driven list building program. This will require all of the above code to be broken up into functions, which adds another level of challenge.

September 18, 2013

I have successfully de-constructed the linked list code and reordered it into functions that are ran selectively from a menu in the main function. The code for which is below:

#include<stdio.h>
#include<stdlib.h>

struct node{
        int value;
        struct node *next;
        };
typedef struct node Node;

Node *createlist(Node *);
Node *displaylist(Node *);
Node *appendnode(Node *);
Node *insertnode(Node *);
Node *removenode(Node *);
Node *sortlist(Node *);
Node *clearlist(Node *);

int main(){

        Node *list=NULL;
        char menuselect=0;

        while(menuselect !='Q'){
                printf("==========What would you like to do?===========\n");
                printf("=====Press 'C' to create a linked list=========\n");
                printf("=====Press 'L' to display the list=============\n");
                printf("=====Press 'A' to append a node into the list==\n");
                printf("=====Press 'I' to insert a node into the list==\n");
                printf("=====Press 'R' to remove a node from the list==\n");
                printf("=====Press 'S' to sort the list================\n");
                printf("=====Press 'D' to clear the list===============\n");
                printf("=====Press 'Q' to quit=========================\n");
                printf("===============================================\n");
                scanf("%c", &menuselect);
                if (menuselect == 10)
                        scanf("%c", &menuselect);
                else
                        getchar();

                switch (menuselect){
                        case 'C':
                                list=createlist(list);
                        break;
                        case 'L':
                                list=displaylist(list);
                        break;
                        case 'A':
                                list=appendnode(list);
                        break;
                        case 'I':
                                list=insertnode(list);
                        break;
                        case 'R':
                                list=removenode(list);
                        break;
                        case 'S':
                                list=sortlist(list);
                        break;
                        case 'D':
                                list=clearlist(list);
                        break;
                        case 'Q':
                                printf("Goodbye, cruel world\n");
                        break;
                        default:
                                printf("Amplify Query!\n");
                }
        }
}

//Creates linked list
Node *createlist(Node *list){
        int input=0;
        Node *temp=NULL;
        while(input!=-1){
                printf("Enter a value (-1 to end): ");
                scanf("%d", &input);
                if(input != -1){
                        if(list == NULL){
                                list=temp=(Node*)malloc(sizeof(Node));
                                temp-> next=NULL;
                                list-> value=input;
                        }
                        else{
                                temp->next=(Node*)malloc(sizeof(Node));
                                temp->next->next=NULL;
                                temp->next->value=input;
                                temp=temp->next;
                        }
                }
        }
return(list);
}

//Display linked list
Node *displaylist(Node *list){
        int input=0;
        Node *temp=NULL;
        temp=list;
        while(temp!=NULL){
                printf("[%d](%d)->\n",input, temp->value);
                temp=temp->next;
                input=input+1;
                }
        printf("NULL\n");
return(list);
}

//insert new node into list
Node * insertnode(Node *list){
        int input;
        int seeker;
        Node *temp, *temp2;
        temp=list;
        printf("Which node would you like to insert before? :");
        scanf("%d", &input);
        temp=list; 
        for(seeker=0;seeker<(input-1);seeker++){
                temp=temp->next;
                }
        if(input==0){
                printf("Enter value to insert: ");
                scanf("%d", &input);
                printf("\n");
                temp2=(Node*)malloc(sizeof(Node));
                temp2->value=input;
                temp2->next=NULL;
                temp2->next=temp;
                list=temp2;
                }
                else{
                        printf("Enter a value to insert: ");
                        scanf("%d", &input);
                        printf("\n");
                        temp2=(Node*)malloc(sizeof(Node));
                        temp2->value=input;
                        temp2->next=temp->next;
                        temp->next=temp2;
                        }
return (list);
}

//Append after specified node
Node *appendnode(Node *list){

        int input=0;
        int append=0;
        Node *temp, *temp2;
        temp=list;
        printf("Which node would you like to append? :");
        scanf("%d", &input);
        temp=list;
        for(append=0;append<(input);append++){
                temp=temp->next;
                }
        printf("Enter a value to append :");
        scanf("%d", &input);
        printf("\n");
        temp2=(Node*)malloc(sizeof(Node));
        temp2->value=input;
        temp2->next=temp->next;
        temp->next=temp2;
return(list);
}

//Sort the list
Node *sortlist(Node *list){
        Node *temp;
        temp=list;

}

//Clear the list
Node *clearlist(Node *list){
        Node *temp;
        temp=list;

}

//Remove Node
Node *removenode(Node *list){
        int input;
        int remove;
        Node *temp, *temp2;
        temp=list;
        printf("Which node would you like to remove? :");
        scanf("%d", &input);
        printf("\n");

        for(remove=0;remove<(input-1);remove++){
                temp=temp->next;
                }
        if (input==0){
                temp2=temp->next;
                temp->next=NULL;
                list=temp2;
                }
                else{
                        temp2=temp->next;
                        temp->next=temp2->next;
                        temp2->next=NULL;
                        }
return(list);
}

This was challenging because it really did constitute the first time that i had to take a lengthy body of code and form it into functions that interacted well with each other. Luckily, Each function accepted the same thing and return the same thing, being 'list' in this case. My clear and sort functions still are not implemented as of yet.

September 19, 2013

Today we derived the code to make an insert function for our still-in-progress doubly linked list.

List *insert(List *myList, Node *place, Node *newNode){
      if(place==myList->start){
              newNode->next=place;
              place->prev=newNode;
              newNode->prev=NULL;
              myList->start=newNode;
      }
      else{
              newNode->next=place;
              place->prev->next=newNode;
              newNode->prev=place->prev;
              place->prev=newNode;
      }
return(myList);
}

This function will place a new node with its →next pointing to place (place being the user specified node to insert before) and its previous points to the previous of 'place', then place→prev is directed to point to the new node.

September 20, 2013

Today we derived the code to remove a node, function named getNode. The code is as follows.

List *getNode(List *myList, Node **place){
        if(myList->start->next==NULL){
                myList-start=NULL;
        }
        else if(*place==myList->start){
                myList->start=myList->start->next;
                myList->start->prev=NULL;
                (*place)->next=NULL;
        }
        else if(*place==myList->end){
                myList->end=myList->end->prev;
                myList->end->next=NULL;
                (*place)->prev=NULL;
        }
        else{
                (*place)->prev->next=(*place)->next;
                (*place)->next->prev=(*place)->prev;
                (*place)->prev=(*place)->next=NULL;
        }
return(myList);
}

This function will allow us to remove a node. More than removing it, we will be able to use this function to remove a node and use the insert function to place it elsewhere.

September 21, 2013

This morning I had thought that I had stumbled upon an epiphany with the sort function in our single linked list. Unfortunately it behaves bizarrely, but I guess it's a start.

Node *sortlist(Node *list){
     Node*temp;
     Node*temp2;
     temp=temp2=list;
     while(temp->next != NULL){
          if(temp->next->value < temp->value){
               temp->next->value = temp2->value;
               temp->value = temp2->next->value;
               temp=temp->next;
               list=temp;
          }    
     }
return(list);
}

Hey… I guess documenting failure is also part of the process, right?

September 25, 2013

Today we broke up our program into multiple files. The embodiment of the #includes, the #defines, and the function prototypes were place into a header file. The body of main and the function definitions were separated into their own files with the header file #included in them. These were them compiled together. This is useful because it allows for function use that is not dependent on the program itself, this is important for building ever more useful libraries.

September 26, 2013

Today I successfully (FINALLY) took user input out of the insert function and now have the main function taking user input and passing it to the insert function. Today was a good day, even if I still feel that there is water in my lungs.

UPDATE: So, now I have the create list, display list (forward and back), insert, and the append function working correctly on the doubly linked list. I am nearly there on the remove function. That double pointer is really throwing me off. It's not compiling, and as is usually the case, the compiler error is just a tad too vague. I had hopes of having my doubly linked list being up to snuff before Friday. I'm relatively confident that it will not be.

September 27, 2013

Whelp, I now have a fully functional doubly linked list…fully functional if you accept the fact that I have yet to implement the sort or clear function. The doubly linked list is broken into separate files with a header and compiled together. So, yeah… good stuff.

October 2, 2013

Today we took a knowledge assessment, it was pretty terrible. After class was over I had to eat like 4 large pizzas to make myself feel better.

October 4, 2013

We collectively did poorly on the assessment, so, Mr. Haas reviewed with us briefly and we did it again. Thankfully, the second attempt turned out much better.

We also did the second portion of the knowledge assessment, this actually went fine.

October 16, 2013

A lot has happened… We are moving beyond our double linked list assembly and transitioning into stacks. This creates a new ceiling of complexity. Much in the same way that our doubly linked list manipulated nodes, our stack manipulates lists.

October 17, 2013

We now have a shiny Makefile to make use of for our list/stack. I was able to implant the relevant code for our doubly linked list, however I am having issues compiling the stack.

October 25, 2013

Stacktest now correctly works after adding a few more conditions within my function bodies. With the success of stacktest, I can only assume that my functions are all green-lit. I suppose it is now time to make my FORTY THIEVES CARD GAME. (all caps is used for dramatic effect)

October 30, 2013

Today we begin talking about binary trees. There are three methods of traversal in a binary tree; pre order, in order, post order. These three traversal methods dictate how the data will be ordered once the tree is finished. pre order = polish notation. post order = reverse polish notation. KNOWLEDGE. We can make certain assumptions of the binary tree, interestingly. The left most node will always be the smallest value, conversely, the right most node will always be the greatest value.

Nov 7, 2013

Binary tree has begun. It is currently failing, however.

We need to make an iterative based, stack based, and recursive based transversal of our binary tree. I am currently working on setting up the tree.

Nov 8, 2013

Losing sleep over binary tree. So simple conceptually, having trouble with implementation. Thinking about turning to hardcore drugs to alleviate my woes.

UNIX/Linux Fundamentals Journal

August, 28 2013

Today began the semester for Unix/Linux.

We briefly discussed a series of commands to use within the terminal.

who : displays the list of users currently signed into lab46, along with the time that they logged in and the amount of time a user has been idle.
w : a slightly different list of current users, similar to to the 'who' command. Also shows what the user is currently doing.
pwd : shows your absolute path, where you are currently working.
cd “directory” : changes your working directory to the specified directory.
cd : changes your working directory to the home directory.
man “command” : displays a manual giving various uses and modifiers of the specified command.
ls -l : a more detailed file list of your working directory.
whereis “command” : shows the path listing of the specified command.
whoami : Displays the current user signed in.
pom : displays the current phase of the moon.
cal : displays a calendar.
date : displays a date.

August 30, 2013

Today we discussed the early philosophy of Unix.
1). Small is beautiful. The meaning behind this is pretty simply to avoid unnecessary or ineffective features. This may seem to be a reduction of user-friendly features, but one could argue that with a slim design there would be fewer extraneous features to confound the user.

2). Do one thing and do that one thing extremely well. This could be summed up with the example that the command 'ls' lists files and certain attributes. It lists files, and it only lists files. The move command 'mv' is used to move files and can be used to rename a file. This is all it does.

3). Everything is a file. This, as far as I am aware, refers even to hardware, which is considered a “file”. If you plug in an external hard drive, that hard drive is mounted as a file. Even your monitor is a file.

We talked about I/O streams:
0 STDIN
1 STDOUT
2 STDERR

It is possible to redirect the I/O streams to specified locations. For example we can type:

 echo "gumby" > emptyfile

Instead of “gumby” being displayed to our monitor, which is where stdout would normally flow to, it is instead fed into the file 'emptyfile'. Then, if we were to examine the contents of 'emptyfile' we would see that it now contains “gumby”.

'>' redirect STDOUT (write)
'»' redirect STDOUT (append)
'2>' redirect STDERR (write)
'2»' redirect STDERR (append)

Were we to redirect STDOUT using '>', we would be writing over any existing content. If, instead, we used '»' we would be redirecting STDOUT to append to the destination. This would add the redirected material to the destination without writing over its previous contents.

Some more commands we learned are:
cp - copies specified file to specified location.
mv - moves specified file to specified location, also used to rename a file.
ln or 'ln -s' - allows us to link two files. when no modifier is used, the two linked files will have their contents mirrored. when the modifier -s is used, the link is symbolic, this does not mirror contents but can be used to make a short cut of sorts for a file.
rm -i or rm -f interactive or force, allows you to remove files, the modifier -i asks you if you're sure you want to remove a file before the removal occurs.

September 1, 2013

While not explicitly a part of the class; I wanted to get some code off of my Discrete directory but I was at home. Using putty to view and retype all the code on my computer locally would have worked, but I didn't want to do this. I used putty to access lab46, then used alpine, then created an email and fumbled around until I figured out how to attach a file. I then emailed this to my home email account, thus I did not need to retype the code.

September 4, 2013

Today we discussed a few different concept. The '$' symbol generally stands for variable expansion and all caps variables are called environment variables. We can define variables too, for example: stuff = “things” defines a variable named stuff. Were we to type 'echo $stuff' then the variable expansion of stuff, which in this case is “things” would be displayed to STDOUT. These local variables are stored in memory. when you log out or make a new session terminal, the variable defined as 'stuff' no longer has meaning.

absolute path refers to the complete path beginning at root. Your relative path is based on your current location. For example, if you were located in the src directory and had a subdirectory called 'blarg', typing 'cd blarg' would move your working directory to 'blarg'. If you were not currently located in the src directory, typing 'cd blarg' would not work because 'cd blarg' is a relative path.

Files that start with '.' are listed as hidden and you cannot see them be default. 'ls -a' shows all files, including hidden ones.

We also talked about file permissions. typing 'ls-l' will display permissions for the various files in the directory. For example: rwxr-xr-x gives read/write/execute rights to the owner, read/execute rights to the group, and read/execute rights to global. Permissions can be viewed as an octal number where each octet refers to owner or group or global. the owner having rwx privileges would be equivalent to 7. The group category having only read and execute privileges would be 5, and same for global with the same permission set. Essentially this gives us the octal of rwxr-xr-x as 755.

Using the '|' command can be used to join commands together. An example: “ls -l | less” joins “ls -l” with “less”

September 6, 2013

WILD CARDS!
WILD CARDS!
WILD CARDS!
WILD CARDS!

Today we discussed at great length the use of wild cards. Wild cards are characters with special meaning that will allow us to accomplish tasks more efficiently within a unix/linux based system.

There are at least 4 wildcards that we used in class:
'*' - The star wildcard allows us to search for 0 or more of anything within a search field.
'?' - The question mark wildcard matches 1 character length of any character.
'[]' - Bracket wildcard will match any of the specified character class.
'[^]' - Inverted character class wildcard will exclude any of the specified character classes.

An example of using the wildcards:

 ls ?[e][^x]*

This will filter the results of the ls command to only display files that have a file name where 'e' is the second character of the filename, and where 'x' cannot be the third character of the file name. The subsequent '*' wildcard also lists any files that meet the previous requirements and are longer in filename.

September 7, 2013

Case Study ox1: Archive handling Exercise:
I copied archive1.tar.gz and archive2.zip to my home directory by using the following while in the archives directory:

cp [a]* /home/jvanzil4|ls -l /home/jvanzil4


I extracted archive1.tar.gz with the following command:

 tar -xfv archive1.tar.gz


I extracted archive2.zip with the following command:

unzip archive2.zip


After renaming abc.txt to def.text, I used the following command to create an archive of the extracted files:

tar -cfv arc.tar archives


Now that arc.tar exists, we can compress it using gzip. The command for that operation is as follows:

gzip -9v arc.tar


the modifier of '9' refers to the level of compression, where 9 would be the most compression. now that we have a compressed archive named arc.tar.gz, we will move it to my unix directory.

September 13, 2013

Added Jonathan Swift's A Modest Proposal to my .plan file.

September 18, 2013

Today we discussed a great many things, notably we discussed multiple variations of the kill command.

We also discussed some commands bound to keys on the keyboard. For example, pressing control+c actually issues a “signal interrupt” to what ever process is running in the foreground. Control+d is bound to the EoF (end of file) command. This end of file command is interesting because on a linux/unix system nearly everything is considered a file. So, naturally executing an end-of-file will terminate many processes currently in the foreground. Control+z executes a signal suspend. This is notable because it does not terminate a process, it merely “pauses” it until it is told to resume.

typing “jobs” can show us a list of running or stopped processes. Along with the listed jobs, we are also shown a job ID, using 'bg' for background or 'fg' for foreground, along with the listed jobID, we can individually order certain processes to run in the background or foreground. One caveat is that for a prcoess to run in the background it cannot use any sort of user input for its functionality.

The command whowatch gives us a detailed look at running processes, and to which user those processes belong.

the command 'kill -l' will give us every single different sort of kill signal there is, of which there are 64. Some kill commands will close up subsequent child processes spawned by the parent to be killed. This is not true for kill -9. It is jokingly referred to as the ultimate kill command, it will not close or cleanly end children processes. Kill -9 can potentially create “zombies”, which are processes for which there is no parent in governance.

September 20, 2013

Case Study 0x1

After unpacking badname.tgz there are now three new subdirectories. Entitled: Challenge, Example, Exercise.

Within the Example subdirectory there is a file with spaces in its name. The contents of that file are “This file has just spaces in its name.”

Exercise:

Using the '*' wild card I used 'cat' to open three files. The three commands I used were:
lab46:~/badname/exercise$ cat just*
contents: “Simple, but simpler without the spaces!”
lab46:~/badname/exercise$ cat '#'*
contents: laLAA… pretend this is a pico temp file.
lab46:~/badname/exercise$ cat one*
contents: spaces, commas, two types of quotes… oh my!

Using the '\' wild card I used 'cat' to open three files. The three commands I used were:
lab46:~/badname/exercise$ cat \?\?\?\ c*
contents: This file has spaces and ?'s in its name.
lab46:~/badname/exercise$ cat \$USER*
contents: Watch out for those $ signs
lab46:~/badname/exercise$ cat \*\*\*\ w*
contents: Care must be taken when using the '!' symbol, as it deals with history.

using the “ or ' shell quoting I used to 'cat' to access three files. The three commands I used were:
lab46:~/badname/exercise$ cat “change my\ name.file”
contents: This file has spaces and a backslash in its name.
lab46:~/badname/exercise$ cat ”( parenthesis & other odd things )“
contents: Are we having fun yet?
lab46:~/badname/exercise$ cat 'compress “this” file.data'
contents: this file has spaces and double quotes in its name.

What was interesting about this last one is that I had to use single quotes or else the shell was getting confused, as there were already double quotes in the file name.

Deleting the file in the challenge sub directory was difficult. It thwarted most of my attempts.

surprisingly, when i failed to remove the file for the tenth time, I sat there, then I noticed that the terminal was telling me the answer:

Try `m ./'- challenge round -'' to remove the file `- challenge round -'.\\


So…I did exactly that. I am not sure if that constitutes as cheating, but there it is:
lab46:~/badname/challenge$ rm ./'- challenge round -' rm: remove regular file `./- challenge round -'? y

September 20, 2013

Lab 0x2

1a. 'cd /' is used to access the root directory 1b. yes 1c. /home is used extensively. We may have used /usr before as well. 1d. I am not able to access the root directory

2c. cd /home\\cd jvanzil4

3b. /tmp

4a.relative
4b.relative
4c.absolute
4d.absolute

5. current working dir: /home/jvanzil4
5ab. No, it does not change. '.' represent your current working directory. 'cd .' would be changing from your current directory to go into… your current working directory.
5c. No, it does not change because 'cd ..' would be to go to the parent directory of your working directory. the root has no parent directory so 'cd ..' accomplishes nothing.

6a. /var/log contains mostly normal files.
6b. /dev contains an overwhelming number of special files, as well as some link files and directories
6c. / contains a few links but mostly directories
6d. /etc/init.d contains normal files

7 the vim utility belongs to the root account. owner, group, and global can all read, write, and execute the vim utility.

8a. 640 octal permission for daemon.log 8b. 644 octal permission for resolv.conf 8c.

September 27, 2013

We continued using scripts and the 'xte' command, along with xpaint to draw a picture for us without directly moving the mouse ourselves. I drew a crude house and a tree. The script itself kills any pre existing instances of xpaint, then opens xpaint with a specific sized canvas. xte then interacts with STDIN to create input. It's interesting stuff.

September 30, 2013

Lab0x3

2a. 'wc -l passwd' 2b. 27

3a. root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
irc:x:39:39:ircd:/var/run/ircd:/bin/sh

3b. 'head –lines=16 passwd'

4a. sshd:x:101:65534::/var/run/sshd:/usr/sbin/nologin
fetchmail:x:102:65534::/var/lib/fetchmail:/bin/false
ntp:x:103:104::/home/ntp:/bin/false
tss:x:104:65534::/home/tss:/bin/false
statd:x:105:65534::/var/lib/nfs:/bin/false
messagebus:x:106:111::/var/run/dbus:/bin/false
avahi:x:107:113::/var/run/avahi-daemon:/bin/false
cl-builder:x:108:115::/usr/share/common-lisp/:/bin/false

4b. 'tail –lines=8 passwd'

5. Interestingly, tail -f allows the terminal to be updated as the file is appended. I did not do this with a partner, I opened two terminals from home and SSH'd into lab46.

6ab. 'tail -f' would be useful in a group work environment when you want to see what is being appended to a given file. This could certainly have a wide range of applications. Tail -f could also be useful when you want to see the frequency of which entries are added to a system file.

Playing around in vi is interesting. It is sort of like exploring an earth like planet that is not earth and have living things on it that resemble, but are not identical to, life on earth. I would like to say that I will dedicate enough time for it to honestly become my primary text editor, though this is unlikely.

Case Study0x3

1b. ASCII text file
1c. The result of 'cat' displays this: “This is a simple text file. It contains ASCII text.”
1d. gzip compressed data, was “file.txt”, from Unix
1e. 'file file.txt.gz' now reflects that it has been compressed with the fastest compression - states 'max speed'

2. Puzzle box was great. Had me scratching my head in the beginning, but like all good challenges it wasn't soul shatteringly difficult. Shatteringly is now a word.

October 2, 2013

Today we continued our foray into scripting, this time we used loops and arrays to create a pokemon battle experience calculator. That was not a typo, we made a pokemon battle experience calculator.

October 6, 2013

Lab 0x4
1c) yes
3b) It records a history of the last commands to be executed on the command line
4a) /bin/bash
4b) /Maildir
4c) xterm
4d) /home/jvanzil4
5b) echo $PATH
6a) 'ls –color=auto'
6b) –color=auto
6c) colorize the output of ls
7a) the output of ls is no longer colorized
7b) no
7c) –color[=WHEN]
8b) alias ls=“ls –color=auto”
8c) yes
8d) yes, the output is now colorized
9e) 529
9g) yes
10b) my last entered command is displayed
10d) it is probably one of the best short cuts available
11b) It suggests a logical auto complete, suggests /usr
11d) suggests the next logical step, in this case /usr/bin
11f) /usr/bin
11g) gives all possible logical options for the completion of what was already entered.
11i) tab after entering vimt, because there are more than one file in the directory that contain “vim”, vim+t makes it a unique identifier.

October 23

1b)~/src/unix/shell
1d) touch “filename”

2b)all of the newly created files are output through ls
2d)no file can be located because no file matches the file name 'file'
2f)file2 and file3 are listed because 'ls file[23]' is telling to ls to return files that are named either file2 or file3
2h)file2, file4, file41, filea - ls is looking for file names that begine with file, then have a 2, a 4, or an 'a' as the next character. The '*' then looks for any filenames that are longer, while still meeting the previous requirements, hence file41 is also listed.

3b) the motd is in file1
3d) This is test is now in file1

4b) file1 now contains only the information supplied from 4a because the redirection wasn't appended, it was overwritten.
4d) grep grabbed the output of ls that contained 'file1' and redirected it into file2

5b)yes, no such file
5d)No, because this is an error, which is not bent to the will of STDOUT
5f)Yes, the error was redirected via 2> into /dev/null
5h)file2 is used as an argument for cat

6) ls /bin | less

 ls /bin | more\\
 

7b)PATH is displayed.
7d)The same thing, double quotes are variable expansion.
7f)$PATH is returned, single quotes are for literal strings.

8a)wc counts the word count when piped along with another command.
8b)wc -l

9b)cat /etc/motd|wc -l
9c)15

10a) ls ????
10b) ls [jtvJTV]*
10c)5, bzcat, bzip2recover,bzless,cat,chvt

11b)Good work! You're done!
11c)cat Long*

October 30, 2013

Today we are using scripts to evaluate and parse specific information out of the winter2014 course list. The command tr 'a' '7' will search for all instances of the letter a and turned them to the number 7. tr '/n/ '' will take all newline and replace them with a space. My course parser is sort of garbled.


cat winter2014-20131025.html|egrep '(^<th class="ddtitle)|(^<td class="dddefault)' | sed 's/^<td class="dddefault">//g' | sed 's/<.td>//g'| sed 's/<th class=.*><.*>//g' | sed 's/.<abbr.*<.a>//g' | sed 's/<abbr.*<.abbr>//g' | sed '/^$/d'

It does some of the things that I want it to do, however it does not do them all.

Lab 0x7

1a)jvanzil4 10091 0.0 0.1 13668 1752 pts/62 SNs Aug28 0:00 /bin/bash jvanzil4 10094 0.0 0.2 42552 3400 pts/62 SN+ Aug28 24:10 irssi jvanzil4 20624 0.0 0.1 13628 1964 pts/38 SNs+ 08:35 0:00 -bash jvanzil4 20631 0.0 0.1 13628 1972 pts/46 SNs 08:35 0:00 -bash jvanzil4 20696 0.0 0.0 8588 996 pts/46 RN+ 08:47 0:00 ps u

1b) no, ps by itself will not. 1c) ps -e would give you every process

2a) ps -e u 2b) I am unable to locate the inetd daemon. 2c) The top processes seem to be irrsi related. Otherwise, it appears no user is doing much of anything on lab46

3a) file command output count.c as an ascii c program text 3c) after compilation it can be run with ./count. It runs as it was meant to. Without something else feeding input into it, it would take a very very long time relying on user defined input.

4a) it took 37 seconds to reach the MAX_NUMBER condition. 4b) This process is displayed at the top of the list, listing 100% cpu utilization.

5a) I used this incantation: “sleep 8; ls /var > multitask.lab.txt &” the sleep command conjoined with the output of ls going into multitask.lab.txt

6b) I am not immediately able to logout, the terminal informs me that there are stopped jobs 6c) This is definitely put in place as a safe guard against forgetting that you had jobs that were stopped in the background.

7a) the 'jobs' number for links is #2 7b) brought it to the foreground, suspended it again. 7c) yes, links is still in the job listing 7d) 'fg 1' 7f) No, cat is no longer in the job listings 7h) the job list is now empty.

8a) hangup = kill -1 8b) terminate = kill -15 8c) kill = kill -9 8d) interrupt = kill -2

9a) Yes, both of my ssh sessions are listed. 9b) 38 and 57 9c) 20623 and 24120

10b) kill -15 24120 10c) on the terminal that was terminated, the message generated was “Connection to lab46.corning-cc.edu closed by remote host. Connection to lab46.corning-cc.edu closed.” 10d) using a who command only displays one session now.

11a) ps -u statd 11b) ps -e|grep “init” the PID is 1 11c) root owns the cron process - cron is a time-based job scheduler. It is useful when you want terminal commands executed at regular intervals.

Nov 8, 2013

Lab 0x8

1b) lab46:~/src/unix/devel$ gcc -o helloC helloC.c

  lab46:~/src/unix/devel$ g++ -o helloCPP helloCPP.cc\\
  lab46:~/src/unix/devel$ as -o helloASM.o helloASM.S\\
  lab46:~/src/unix/devel$ ld -o helloASM helloASM.o\\

1c) All three files return Hello, World! to STDOUT

2b) Yes, there is an error. HelloC is attempting to call a command of the same name, a command which doesn't exist.
2d) Yes, it works. This is different because we are running the name of the file against our current working directory.

3) lab46:~/src/unix/devel$ file helloC.c
helloC.c: ASCII C program text
lab46:~/src/unix/devel$ file helloCPP.cc
helloCPP.cc: ASCII C++ program text
lab46:~/src/unix/devel$ file helloASM.S
helloASM.S: ASCII assembler program text
lab46:~/src/unix/devel$ file helloJAVA.java
helloJAVA.java: ASCII C++ program text
lab46:~/src/unix/devel$ file helloASM2.asm
helloASM2.asm: ASCII assembler program text
lab46:~/src/unix/devel$

4c) HelloC.s is now present in the ls output. 4d) the file command says it is an ASCII assembler program text. 4f) the result of cat returns assembly. helloC.s is assembly language.

7b) hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped 7d) yes, it is the same output as file hello 7e) ./hello outputs “Hello, World!”

8a)cp helloC.c ~/src 8b) yes. 8d)make helloC

9d) running 'make' builds the code.

10a) helloC - 6546 bytes

   helloCPP - 8369 bytes
   helloASM - 935 bytes

10b) though helloASM is smaller by far, all three have no discernible differences in execution time. This is most likely due to the three programs being very simple. 10c) helloJAVA.java is 846 bytes. the execution time was noticeably longer (by noticeable, i mean a fraction of a second) 10d) it would stand to reason that the higher level a language is, the smaller the compiled code will be. This should be due to the nature of higher level languages requiring fewer user directed instructions. This may be misleading though. I would assume that upon execution, a higher level language-derived executable will consume more resources than a lower level language. Less work being required by the coder to code should probably result in the compiler doing more work.

Case study 0x8

Nov 8, 2013

Amazing Multi-Day UNIX activity - in groups or individually - on a project machine or virtual machine, instal the latest official release of OpenBSD -after/upon install, also do the following: -enable SSHD, verify that you can log in over the network -create some users -install/customize some packages, such as bash, gnu core utils, X, a window manager (fvwm, fluxbox, or something else), vim, webserver.

Nov 13, 2013

Am running openBSD on a virtual machine on my laptop. Successfully SSH'd into lab46, pretty nuts stuff.

Nov 15, 2013

Mr. Haas has now tasked us with:
-verify you can in fact SSH to your openBSD box from a POD.
-obtain and set up the openBSD ports on the box (no, not those kind of ports)
-from ports, install:
-globe (under geo)
-(something from games): abuse, blobwars, amph, etc.
-a console-based file manager, such as midnight commander(mc), or ranger
-also: find (and tail) various log files. Determine where information is logged for user logins, and try to ascertain the purpose of the other logs.
-see if you can set up a secure “passwordless” ssh (hint: ssh-agent)
-set up sudo (instal from ports if necessary) so you don't need to become root all the time.
-document your travels/discoveries on your opus.

Lab0x6

1a) ls -l displays permission sets 1b) the permissions for this new script are 422 1c) chmod will allow for permissions to be changed 1d) chmod 700 lab06script.sh 1e) it runs.

2e) the subtraction was performed with “let age=`date +%Y`-$birthyear;” 2f)

echo "please enter the year of your birth.";
read birthyear;
echo "You entered the year: `echo $birthyear`";

let age=`date +%Y`-$birthyear;
echo "You are `echo $age` years old";

3e) It selected a pseudo random number between 0 and 22. 3f)

#!/bin/bash

pick=$((RANDOM % 20));

echo "Guess a number between 1 and 20.";
read guess;

let win=0;

for((chance=0;chance<3;chance++));do
if [ "$pick" -eq "$guess" ]; then
        if win=0; then
                echo "Hurray you disgusting wizard, the number was: $pick and you guessed: $guess.";
                let win=win+1;
        fi
else
        echo "Sorry, you guessed $guess, that is incorrect. ";
        echo "Please select a new number.";
        read guess;
fi      
done
if [ "$pick" -ne "$guess" ]; then
echo "You have eliminated your chances. The number was $pick, you piece of shit.";
fi

4b)

for((i=20; i>=2; i-2)); do
    echo "$i"
done

5b) blue
5d)<code> echo -n "First color is: "
let i=1;
for color in red orange yellow green blue indigo violet; do

        let i=i+1;
        echo "$color"
        if [ $i -ne 7 ]; then
        echo -n "Next color is: "
        else
        echo -n "The last color is :"
        fi
done

Histogram script:

#!/bin/bash
#
#

if [ -z "$1" ]; then
        echo -n "Enter a path: "
        read path
        chk=`ls $path 2>&1|grep 'No such file'|wc -l`

        if [ "$chk" -eq 1 ]; then
                path=`pwd`
        fi
else
        path="$1"
fi

echo $path
cd $path
max=0

for file in `ls -1d *`;do
        c=`echo $file|wc -c`
        let data[$c]=${data[$c]}+1
        if [ "$max" -lt "$c" ]; then
                max=$c
        fi
done

for ((i=1;i<=$max;i++));do
        #echo -n "$i:|-\/-|:"
        count=${data[$i]}
        printf "%2d |" $i
        if [ -z "${count}" ]; then
                count=0
        fi
        for((j=0;j<$count;j++));do
                echo -n "|"
        done
        echo
done

Case Study 0x6

1c) xvda1, xvda2, xvda3 are all block files. 1d) hvc0, hvc1, hvc2 are all character files.

2a) Filesystems:

  /dev/xvda1
  tmpfs
  udev
  /dev/xvda2
  nfs:/home
  nfs:/lib/mail 

2b) /dev/xvda1 2c) nfs:/home 2d) /dev/xvda2 2e) /dev/xvda3 houses the swap 2f) appears to be on a virtual disk

4c) permissions for my terminal are 620 4d) messaging is yes

5c) after switching mesg to 'n' the permission have changed for my tty# 5d) this changes the ability for people to message you by making your “file” unwritable to members of the group where previously the group had the ability to do so.

7c) cat /etc/motd > /dev/null 7d) /dev/null may be useful in a certain situation where you would not want certain output to go anywhere, but it has to go somewhere, perhaps /dev/null is the garbage can on output.

Case Study 0x5

Man, I really had fun making this. I now understand the 90's. My new homepage's URL is: http://lab46.corning-cc.edu/~jvanzil4/jonhomepage.html

Lab 0x9

1a) cat passwd | grep System 1b) grep filters through the output of cat and looks for “System”. What ever line contains the grepped for string is returned.

2a) cat passwd | grep^[b-d][aeiou] 2b) this grep search only returns entries where the first character is b,c, or d; and the second character can only be a vowel. 2c)This could be beneficial when you already know the naming conventions used for entries or content in a file or directory. If you know more-or-less what you want then you can tailor grep to look for it exclusively.

3a) using cat passwd | grep ^[jtvJTV] returned only one match: tss:x:104:65534::/home/tss:/bin/false 3b) incantation used : cat passwd | grep ^[r][aeiou].*[h] only returned one match : root:x:0:0:root:/root:/bin/bash

4a) %s/centre/center/ 4b) %s/CENTRE/CENTER/ 4c) %s/<b>/<strong>/ 4d) %s/<\/b>/<\/strong>/

5a) I found it by doing a file words, it linked to a patch /etc/dictionaries-common. I then did a ls-al to find the file location that is being linked, which is in /usr/share/dict/american-english 5b) the file is made up of dictionary words. 5c) using cat american-english | wc -l I am able to see that there are 98569 entries.

6a) cat american-english | grep ^…..$ | wc -l = 6685 6b) cat american-english | grep^[jtvJTV].*$ | wc -l = 7845 6c) cat american-english | grep^[jJ].*[tT].*[vV]$ | wc -l = 0 6d) cat american-english | grep^[aeiou].*[aeiou]$ | wc -l = 1731 6e) cat american-english | grep^[jtvJTV][aeiou].*[est]$ | wc -l = 3464 6f) cat american-english | grep^[^jtvJTV].*$ | wc -l = 90723 6g) cat american-english | grep^[^t][^h]..*$ | wc -l = 90669 6h) cat american-english | grep^..[e]$ | wc -l = 72 6i) cat american-english | grep ^.*[b][o][b][^b]$ | wc -l = 4 6j) cat american-english | grep ^[b][l][u][e].*$ | wc -l = 37 6k) cat american-english | grep ^.*[^aeiouY].*$ | wc -l = 98562 but this must be wrong 6l) cat american-english | grep ^[^aeiouY].[abcd].*[aeiou]$ | wc -l = 1549

case study 0x9

1a) cat pelopwar.txt | grep “coast” | wc 1b) 9 1c) cat pelopwar.txt | grep “coast\>” | wc 1d) 8 1e) cat pelopwar.txt | grep “Dorian$” 1f) cat pelopwar.txt | grep “^Again”

2a) cat pelopwar.txt | egrep '^(Athens|Athenians)' 2b) cat pelopwar.txt | egrep '^(Athens|Athenians)' 2c,d) cat pelopwar.txt | egrep '(Corinth|Corinthians)$'

3b) No, fgrep does not allow for the inclusion of regular expressions

4a) last | grep ^[jtvJTV] | head -4 output is :

jmendoza pts/82       pool-96-238-196- Thu Dec 12 01:08   still logged in   
jmendoza pts/53       pool-96-238-196- Thu Dec 12 00:59   still logged in   
jmendoza pts/30       pool-96-238-196- Thu Dec 12 00:59   still logged in   
jmendoza pts/8        pool-96-238-196- Thu Dec 12 00:59   still logged in 

4b) lastlog | sort | grep ^[e-g] | head -4 outpt is :

eberdani         pts/63   10.100.20.29     Tue Feb 22 10:12:22 -0500 2011
efarley                                    **Never logged in**
egarner                                    **Never logged in**
egleason         pts/50   cpe-24-94-60-90. Thu Dec 20 17:28:38 -0500 2012

Lab 0xB

1a)cat sample.db | grep Freshman 1b)cat sample.db | grep Freshman | sort 1d)5

2a) the result is “is” 2b) echo “hello there:this:is:a:bunch of:text.” | cut -d”:“ -f1,6 2c) I still have a single colon

3a) Yes, the colon is gone. 3b) echo “hello there:this:is:a:bunch of:text.” | cut -d”:“ -f1,6 | sed -e 's/t/T/g' 3c) echo “hello there:this:is:a:bunch of:text.” | cut -d ”:“ -f1,6 | sed -e 's/[.]/*/g' 3d) hello there:text*

4a) tr “\r” “\n” < file.mac > file.unix also.. the lawyer was hit repeatedly. By the same car. Am i right? eh? eh? And airplane food?! 4b) tr “\n” “\r\n” < readme.unix > readme.dos 4c) tr “\r\n” “\r” < dos.txt > dos.mac

5a) cat sample.db | grep ^[A-Z] 5b) cat sample.db | grep ^[A-Z] | cut -d”:“ -f3 | sort 5c) cat sample.db | grep [A-Z] | cut -d”:“ -f5 | sort | sed -e 's/*/ /g' =14

6a) cat pelopwar.txt | head -22 6b) cat pelopwar.txt | tail -4 6c) cat pelopwar.txt | head -48 | tail -16 6d) cat pelopwar.txt | tail -2 | head -4

opus/fall2013/jvanzil4/start.txt · Last modified: 2014/01/19 07:56 by 127.0.0.1