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

Assume a Java file test.java has been compiled in current working directory. Wri

ID: 3809168 • Letter: A

Question

Assume a Java file test.java has been compiled in current working directory. Write a single line UNIX command to run this Java program at background and redirect the output to a file log.txt. Write a single line UNIX command to mail only the process ID of running Java program test to the email address In a Bourne shell script, what command we can write to print out the value of second argument from command line? Write a single line UNIX command to list all C files matching the two conditions below the length of filename (excluding ".c") is 5 filename (excluding ".c" ending with "exp" Write a single line UNIX command to move all the .sh files from current folder to parent directory. Write a single line UNIX command to count the number of characters in the message "I am working on exam 2" In the format string %5.21f, explain the meaning of 5, 2 and lf respectively. And what will be printed for expression 123 with this format string? Rewrite the following loop so that its body is empty for (n = 0; m > 0; n++) m + =2 Does the following statement always compute the fractional part of f correctly (assuming that f and frac_part are float variables)? Frac_part = f - (int) f; If not, what is the problem? What is output after calling function bar twice? void bar(){static int res = 100; printf ("res = %d n res/2);} Tell the difference between [$a == $b] and [$a -eq $b] ?

Explanation / Answer

1. java -jar test.java &> log.txt &

2. $ echo ps -ef|grep test| mail -s "PID" test@gsu.edu

3. We can simply write them after script name separated with space. Goes like :

  # sh myScript.sh abc def

here def : Second command line parameter accessible by $2

4. cd /tmp

find . ! -name . -prune -path './??exp' -type f

5. mv **/*.sh ../

6. $ SO="stackoverflow"

$ echo -n "I am working onexam2" | wc -c

7. In the given statement, 8 states the maximum number of digits in the float variable, the digit after decimal states the maximum number of digits allowed after decimal and 'f' states that the variable is a float variable. The answer with 123 would be 123.00000

8. for (n=0;m>0;n==, m+=2)

9. No, it wont compute the fraction part correctly always, because 'f' being the float variable, and int(f) being the integer, and when you look at a float, it contains less significant digits than say a double or long double. Hence, when you perform numerics on them, you must expect that floats will suffer from larger rounding errors.

10. Due to the fact that static variables retain their values in subsequent function calls, output would be :

res=50

res=25

11. The only differnce is that the first expression is an arithmetic operation whereas the second one is an arithmetic operation. However, both expressions check if the value of two operands are equal or not; if yes, then the condition becomes true. Also, the first expression (arithmetic operation) is always performed on long integers.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote