程序代写代做代考 c++ Hive ECS 40 Practice Midterm #1
ECS 40 Practice Midterm #1
ECS 40 Practice Midterm #1 (125 points)
Commands with options you should know: alias, bg; cd; echo -n; fg; jobs, shift; source; umask, wait.
Utilities with options you should know: chmod octal; compress -c; diff -r; find -name -type -exec –print -size; grep – ilnRvx ; gzip;
head –n, kill -signalID; ln –s; ls -alR; pkill, ps -eulf; rename, sleep; sort –nrtk; tail –n, tar -cxtvfzZ; tee, trap, uncompress -c; wc -lwc;
zip, and how to access portions of string variables.
You should recognize the meaning of awk commands , sed commands, and Bash shell control structures.
All utilities, commands, and shell scripts for this midterm should be based on the tcsh shell.
1. (5 points) Write a command line to display all the files in your hw1 directory and the all of the files in its subdirectories.
2. (5 points) Write a command line to display only the files in your hw1 directory, and not the files in its subdirectories.
Given the following session answer questions 3 to 5.
dec63% ps
PID TT STAT TIME COMMAND
1262 p0 Z 0:00
753 p0 S 0:04 -tcsh (tcsh)
1236 p0 T 0:00 tcsh d.sh
1241 p0 T 0:00 tcsh e.sh
1246 p0 T 0:00 tcsh d.sh
1251 p0 T 0:00 tcsh e.sh
1256 p0 T 0:00 tcsh d.sh
1261 p0 T 0:00 tcsh e.sh
1264 p0 R 0:00 ps
dec63%
3. (8 points) Explain what the Z, S, T, and R each mean in the STAT column of the output from a ps command.
4. (9 points) Write a command line that would print out the information about the first two processes that have a status of T, i.e.,
1236 and 1241
5. (8 points) Write a command line that would print out the number of processes that do not have status T, i.e., the output would be
3.
6. (5 points) Write a command line to archive into a file, named arch, all of my header files and C source code files in my current
directory.
7. (5 points) I’ve created a C source code file using a word processor with a umask of 425. What will be its permissions?
8. (5 points) Most system executables are stored in subdirectories named bin. Write a commandline that lists all of the bin
directories on the computer.
9. (25 points) You have a C++ project that uses four files: 1) car.cpp; 2) car.h; 3) body.cpp; and 4) body.h; . Write a
make file that creates an executable named automobile based on the following information:
. car.cpp depends on body.h, and car.h.
body.cpp depends on body.h
10. ( 35 points) Given the following script answer the questions..
1. #! /bin/bash
2. var=`echo $@ | awk ‘{print $NF}’ `
3. if [ -d $var ] ; then
4. for var2 in $@ ; do
5. if test $var2 != $var ; then
6. ln $var2 $var/$var2
7. rm $var2
8. fi
9. done # for
10. else
11. ln $1 $2
12. rm $1
13. fi
a) (3 points) What does line 1 do?
b) (8 points) What does line 2 do?
c) (3 points) What does line 3 do?
d) (3 points) What does line 4 do?
e) (3 points) What does line 5 do?
f) (3 points) What does line 6 do?
g) (3 points) What does line 11 do?
h) (9 points) What does the script, as a whole, script do?