Create a new file named as checkError.sh (vi checkError.sh or nano checkError.sh
ID: 3837759 • Letter: C
Question
Create a new file named as checkError.sh (vi checkError.sh or nano checkError.sh), then include following lines in your checkError.sh.
#/bin/bash
/* Check Error Script */
echo "Try to find out some errors!!!"
# Seach for the words which can be matched by regex [^a]*ce
# And save the output to file "Result"
echo "The regex [^a]*ce can match the string(s):" > Result
grep '^[^a]*ce$' << END >> Result
lance
ace
brace
decide
piece
-ENDHERE
# Check the existence of file "Result"
# Send the content in "Result" to your emailbox
# $1 is replaced by your campusID
ls mail $1 < Result
# $1 is replaced by your campusID
echo "The result has been sent to ${1}@student.gsu.edu"
echo "Congratulations! You have corrected all the errors!"
Correct all the errors in the code. UNIX
Explanation / Answer
#bin/bash
# invalid command /*check Error Script*/
echo "Try to find some errors!!!"
#Search for the words which can be matched by regex[^a]*ce
#And Save the output to file "Result"
echo "The regex[^a]*ce can match the strings(S):" > Result
grep "[^a]*ce"<<END>> Result
lance
ace
brace
decide
piece
END
#Check the existence of file "Result"
#send the content in Result to your emailbox
#$1 is replaced by your campusID
a="test@student.gsu.edu"
mail $a < Result
#$1 is replaced by your campusID
echo "The result has been sent to ${a}@student.gsu.edu"
echo "Congratulations! You have corrected all errors!"
====================================
Result file
The regex[^a]*ce can match the strings(S):
lance
ace
brace
piece
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.