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

Linux. Shell script question Thank you Create a shell script that will take 1 ar

ID: 3838311 • Letter: L

Question

Linux. Shell script question

Thank you

Create a shell script that will take 1 argument and will end with a success exit code if the argument is a whole word in the/usr/share/dict/words file, and it will return an error signal of 1 if the argument is not a word on that file. Your script should not produce any output For example, if your script is called isvalid.sh, then you will see the following output (bad is a word in the dictionary, badd is not a word in the dictionary): [you@blue final]$ ./isvalid.sh bad [you@blue final]$ echo $? 0 [you@blue final]$ ./isvalid.sh badd [you@blue final]$ echo $? 1

Explanation / Answer

#!/bin/bash

if grep "$1" "/usr/share/dict/words"
then
    return 0
else
    return 1
fi

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