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

please write in command line, thx! Go to the hw10 directory and run Unix command

ID: 3774463 • Letter: P

Question

please write in command line, thx! Go to the hw10 directory and run Unix commands that will execute the steps below. When you have a command line that does what the step asks you to do, paste it into hw10.sh using nano or any other text editor. When you have completed all the steps, create an echo statement before the commands for each step, that will print the step number to the terminal. 100 points 1.(1).On a single line, create the following variables with the values given. Variable a with the value 5 Variable b with the value 3 (2).On another single command line, create the following variables with the values given. Variable s1 with the value "foo" Variable s2 with the value "foo" Variable s3 with the value "bar" Print all variables and their values to the terminal. 2.Write a test expression that returns a value indicating true or false when testing whether a is equal to b. Echo the results of this test to the terminal. 3.Write a test expression that returns a value indicating true or false when testing whether a is less than b. Echo the results of this test to the terminal. 4.Write a test expression that returns a value indicating true or false when testing whether a plus b is greater than 9. Echo the results of this test to the terminal. 5.Write a test expression that returns a value indicating true or false when testing whether s1 is equal to s2. Echo the results of this test to the terminal. 6.Write a test expression that returns a value indicating true or false when testing whether s1 is not equal to s3. Echo the results of this test to the terminal. 7.Write a test expression that returns a value indicating true or false when testing whether s1 has a length greater than 0. Echo the results of this test to the terminal. 8.Do the following Copy the directory dir1 from ~ghoffman/course_files/it244_files Copy the directory empty.txt from ~ghoffman/course_files/it244_files Run a single command to show the permissions on the contents of your hw10 directory 9.Write a test expression that returns a value indicating true or false when testing whether dir1 is a directory. Echo the results of this test to the terminal. 10.Write one test expression that returns a value indicating true or false when testing whether empty.txt is readable and is writeable. Echo the results of this test to the terminal.

Explanation / Answer

#!/bin/bash

a=5 b=3

s1="foo" | s2="foo" | s3="bar" | echo "$s1 | $s2 | $s3"

$ [ $a -eq $b ] $ echo $?

$ [ $a -lt $b ] $ echo $?

$ [ ($a+$b) -gt 9 ] $ echo $?

$ [ $s1 = $s2 ] $ echo $?

$ [ $s1 != $s3 ] $ echo $?

s1length=$(echo -n $s1 | wc -m) $[ $slength -gt 0] $ echo $?

ls -l hw10 directory