Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Write a single line UNIX command to list all sh files matching the multiple c

ID: 3740677 • Letter: 1

Question

1) Write a single line UNIX command to list all sh files matching the multiple conditions below: • at directory "/home/test" • filename containing "exam"

2) Write a single line UNIX command to check if "/home/exam2" in the PATH variable.

3) How to obtain the value of command line arguments in a shell program?

4) Write a single line UNIX command to run an executable Java program Hello at background and output the number of lines in the result.

5) Define a symbolic constant(macro) DATA to represent value 3.32 in C .

6) Write a single line UNIX command to output the returned value of last command.

7) In the format string %-8.3lf, explain the meaning of 8, 3 and lf respectively. And what will be printed for expression 123.3455 with this format string?

8) Rewrite the following loop so that its body is empty: for (i = 10; i > m; i--) m=i+m;

9) Rewrite the following if else statement so that only a single line statement is needed: if(n%5||n==3) return n; else return n+1;

10) What are the difference between [ $x == $y ] and [ $x -eq $y ]?

Explanation / Answer

1) find /home/test/ -name "*exam*.sh"

2) echo $PATH | grep -c /home/exam2

3) using $1 to get the first command line argument and $2 to get second, so on and so forth

5) #define DATA 3.32

6) echo $?

7) 8 represents total 8 character space will be reserved for the number, 3 represents only 3 character after decimal will be displayed and lf represent long float

8) for (i=10;i >m; i--){}

9) return (n%5||n-3)? n ; n+1

10) No difference