Menu

Class 2: Homework 2


You must print this sheet out and write/type answers on it!

  1. The file /etc/passwd contains a line for every user with an account on that machine. Examine its contents. Write a single command line that prints out the line from /etc/passwd for each user that is a Class '11 IT (technically SIT) major. Hint: You can have a pipeline with multiple grep processes!
    
    
    
    	  
    
    
    	  
    	
  2. Continuing from the previous problem, Write a single command line that prints out only the name of each user that is a Class '11 IT (technically SIT) major. Hint: by default, the field delimiter for cut is a tab ('\t'), but the -d option changes that. Look under "Examples" in the man page for cut.
    	  
    
    
    
    
    
    
    
    	
  3. The diff utility compares two files and prints out a list of the differences between the two (and does some other stuff). The exit status (which you recall we can query with $?) is 0 if there are no differences, and 1 if there are differences. If your solution to a programming project is myprog, and exin is a sample input file with exout a file containing the proper output for that input, give a single command-line that tests whether your project gives incorrect results. Assume that myprog reads data from stdin and writes results to stdout.