Question: Hello, I have the error message when trying to use a variable to store the diff result. My code, the function and main: I think

Hello, I have the error message when trying to use a variable to store the diff result.

Hello, I have the error message when trying to use a variable

My code, the function and main:

to store the diff result. My code, the function and main: I

think maybe I need the correct way to store the diff result,

I think maybe I need the correct way to store the diff result, thanks.

testi/test_tzl is valid testi/genpwd is valid diff: The current time is 15:49, the weather is sunny, and the password is 74da873b: No such file or directory diff: The current time is 08:49, the weather is sunny, and the password is ab6a7af6: No such file or directory Outputs are identical. Great job! cannot remove "T: No such file or directory cannot remove 'The': No such file or directory cannot remove 'current': No such file or directory cannot remove 'time': No such file or directory cannot remove 'is': No such file or directory cannot remove '15:49,': No such file or directory cannot remove 'the': No such file or directory cannot remove 'weather': No such file or directory cannot remove 'is': No such file or directory cannot remove 'sunny,': No such file or directory cannot remove 'and': No such file or directory MY_OUTPUT="tmp_prog.txt" SOL_OUTPUT="tmp_sol.txt" DIFF_RESULTS="results.txt" DO NOT TOUCH ABOVE THIS LINE YOUR CODE STARTS BELON # check results #Function that compares two input files using diff. If the files are different, #then two messages are printed (one to stdout and one to stderr) and # containing their differences is saved in the current working directory. If the then one message is printed to stdout and the file # containing their differences is deleted after creation. USAGE check results Ellenamel filename2 INPUT filenamel: name of the first file for comparison filename2: name of the second file for comparison function check results { outputl="$ 1" output2="$2" TODO Compare the results using diff and save it to the filename stored in the variable DIFF RESULTS DIFF_RESULTS="$ (diff "$outputl" "$output2")" TODO Check if the file stored in DIFF RESULTS contains any characters if [[ -s "${DIFF RESULTS}" ]]; then echo "Outputs are not identical. :(" echo "Check out ${DIFF_RESULTS} for more details" >&2 else echo "Outputs are identical. Great job!" rm "SIRIFF RESULTS function ??? { O echo "WARNING! TODO on line ${BASH_LINENO[0]} not implemented (or ??? was" "not removed)" 1>&2 } function main { if [ "$#" -le 1 ] || [ "$#" -eq 3 ] || [ "$#" -ge 5 ]; then print_error_and_exit elif [ "$" -eq 2 ]; then check_permissions" check_permissions": prog_compare "$ 1" elif [ "$" -eq 4 ]; then if [ "$1" != "-i ]; then print_error_and_exit else check_permissions "$3" check_permissions "$4" prog_compare_with input fi $2" else print_error_and_exit fi } main "$@" testi/test_tzl is valid testi/genpwd is valid diff: The current time is 15:49, the weather is sunny, and the password is 74da873b: No such file or directory diff: The current time is 08:49, the weather is sunny, and the password is ab6a7af6: No such file or directory Outputs are identical. Great job! cannot remove "T: No such file or directory cannot remove 'The': No such file or directory cannot remove 'current': No such file or directory cannot remove 'time': No such file or directory cannot remove 'is': No such file or directory cannot remove '15:49,': No such file or directory cannot remove 'the': No such file or directory cannot remove 'weather': No such file or directory cannot remove 'is': No such file or directory cannot remove 'sunny,': No such file or directory cannot remove 'and': No such file or directory MY_OUTPUT="tmp_prog.txt" SOL_OUTPUT="tmp_sol.txt" DIFF_RESULTS="results.txt" DO NOT TOUCH ABOVE THIS LINE YOUR CODE STARTS BELON # check results #Function that compares two input files using diff. If the files are different, #then two messages are printed (one to stdout and one to stderr) and # containing their differences is saved in the current working directory. If the then one message is printed to stdout and the file # containing their differences is deleted after creation. USAGE check results Ellenamel filename2 INPUT filenamel: name of the first file for comparison filename2: name of the second file for comparison function check results { outputl="$ 1" output2="$2" TODO Compare the results using diff and save it to the filename stored in the variable DIFF RESULTS DIFF_RESULTS="$ (diff "$outputl" "$output2")" TODO Check if the file stored in DIFF RESULTS contains any characters if [[ -s "${DIFF RESULTS}" ]]; then echo "Outputs are not identical. :(" echo "Check out ${DIFF_RESULTS} for more details" >&2 else echo "Outputs are identical. Great job!" rm "SIRIFF RESULTS function ??? { O echo "WARNING! TODO on line ${BASH_LINENO[0]} not implemented (or ??? was" "not removed)" 1>&2 } function main { if [ "$#" -le 1 ] || [ "$#" -eq 3 ] || [ "$#" -ge 5 ]; then print_error_and_exit elif [ "$" -eq 2 ]; then check_permissions" check_permissions": prog_compare "$ 1" elif [ "$" -eq 4 ]; then if [ "$1" != "-i ]; then print_error_and_exit else check_permissions "$3" check_permissions "$4" prog_compare_with input fi $2" else print_error_and_exit fi } main "$@

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!