Answers
- In the
ifstatement, you need to insert a blank space between the[and the$a. - You need to place a
donestatement after theecho $istatement. - There are a couple of problems with this script. First, the regular expression is set up wrong, which causes you to get either no or incorrect output from this script. Instead of
[a-z]*.sh, it should be [a-z].sh. (The * actually isn’t needed for this.)
You can review the concept of regular expressions in Chapter 9—Filtering Text with grep, sed, and Regular Expressions.
There’s also the fact this regular expression isn’t doing much for us. Unless you have scripts with filenames that consist of nothing but either digits or upper-case characters, this grep command is going to show you all of the scripts in your directory. So, you could probably just omit the grep command altogether, and go with a simple ls *.sh command.
Finally, in the echo statement, you...