Using Unix , do the following calculations in the shell and record the commands
ID: 3860896 • Letter: U
Question
Using Unix, do the following calculations in the shell and record the commands used:
a. Set x to 20, y to 30 times the value of x, and z to five eights the value of y, then print all 3 values out. What were your results? Write the commands used in Unix.
b. Create a file called myfile. Make if executable by you. Write an expression and/or command in the file to (i) add values of x, y, and z (from question a) into a new variable called myadd, and (ii) to print myadd. Run myfile. It should run in a subshell and should not output the summation at this point. Export variables x, y and z from your login shell to the next subshell. Run myfile again. Record your findings before and after the export operations.
c. Using the backquote and the date command, set time1 to be the current time in seconds and set time2 to be the time in seconds of when you were born. Calculate how many hours old you if you're 25 years old. Write the commands used in Unix.
Explanation / Answer
a.)Ans
sh4.3$ x=20
sh4.3$ y=$((x*20))
sh-4.3$ z=$((y*5)) sh-4.3$ echo $x 20 sh4.3$ echo $y 400 sh-4.3$ echo $z 2000
===================================================================
b)
===============================================================
DO ALL THIS AS ROOT
c)time1=$(date +%s)
date -s "2 OCT 2006 18:00:00"
time2=$(date +%s)
diff=$((time1-time2))
echo $
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.