how to wrote a script that reads an input from the reader (dir name) and then answer yes to all questions in the script unless the answer to any of the questions contains a certain string?
example:
$] script.sh dir_name
$] question_1: (answer should be y right after the question is echoed, ie. I do not have to type it)
$] question_2:
if the above output contains a string "THIS IS STRING"
then the answer should be "Enter" otherwise it should be y
$ script.sh dir_name
$ is this a dir? (question 1)
$ y
$ yes this is a good dir (output after answering with y)
$ Does it have txt files? (question 2)
$ [enter] - if the above answer contains "good", or "y" if the above answer does not contain "good"
Please help me with this piece of script.
thanks
---------- Post updated at 05:35 AM ---------- Previous update was at 05:20 AM ----------
So I think I need to know how to assign the output to a variable and then grep the variable to see if it contains "good" in it.
But how to make all answers y unless the output has "good" is my problem