CP1300 UNIX Tools


Programming Tools

(Jason's Notes)

General Purpose Tools


Self assessments


Tutorial Questions


Exam style questions

  1. What are the basic kinds of programming tools?
  2. Explain what each of the programming tools do
  3. In the following makefile:
    all: alpha.o gamma.o
            g++ alpha.o gamma.o -o theta
    
    alpha.o: alpha.cpp beta.o
            g++ -c alpha.cpp
    
    beta.o: beta.cpp beta.h gamma.o
            g++ -c beta.cpp
            g++ beta.o gamma.o -o betaGamma
    
    gamma.o: gamma.cpp
            g++ -c gamma.cpp
         
    If the files "beta.h", "gamma.cpp" have changed what sequence of commands are execute when the command "make alpha.o" is used? Hint: if in doubt, try the programs below...
    // alpha.cpp
    #include <iostream.h>
    #include "beta.h"
    
    void foo(void) {
    
    cout << 42 << endl;
    }
    
    // beta.h
    const int a = 42;
    void foo(void);
    
    // beta.cpp
    #include <iostream.h>
    #include "beta.h"
    
    void foo(void) {
    cout << a << " is the answer" << endl;
    }
    
    // gamma.cpp
    #include "beta.h"
    void main(void) {
            foo();
    }
         
  4. For each of the following independent tasks, write the command which performs each:
    1. search for the files "*.h" under the directory "/usr/include"
    2. search the files in the current directory, displaying occurrences of the string "forty-two"
  5. What does the command "diff file1 file2" do?
  6. What does the command "sort -r alphabet.txt" do?
  7. Write a C++ program that executes the command "ls -lF dir" where "dir" is the first command line argument.
  8. What is the difference between gzip and tar?
  9. What is the effect of the following:
    # gunzip backup.tar.gz
    # tar tf backup.tar
         
  10. What is a command shell?
  11. What is a shell script?
  12. Give examples of common account shell scripts.
  13. What are the two ways of executing a shell script?
  14. Write a shell script that executes "ls -lsa dir" for each directory "dir", given on the command line.
  15. What are two ways that can be used to allow a script to execute recursively.
  16. (Hard Question!) Write a shell script to do the following: