Typical output from this (Web servers) script might be: $
Typical output from this script might be: $ ./my_name Rick NeilOriginal parameters are Rick NeilIs your name Rick ? Enter yes or no: yesHi Rick, nice name$ How It WorksAs the script executes, the function yes_or_nois defined but not yet executed. In the ifstatement, thescript executes the function yes_or_no, passing the rest of the line as parameters to the function aftersubstituting the $1with the first parameter to the original script, Rick. The function uses these parame- ters, which are now stored in the positional parameters $1, $2, and so on, and returns a value to thecaller. Depending on the return value, the ifconstruct executes the appropriate statement. As we ve seen, the shell has a rich set of control structures and conditional statements. We need to learnsome of the commands that are built into the shell; then we ll be ready to tackle a real programmingproblem with no compiler in sight! CommandsYou can execute two types of commands from inside a shell script. There are normal commands that youcould also execute from the command prompt (called external commands), and there are built-in com- mands (called internal commands) that we mentioned earlier. Built-in commands are implemented internallyto the shell and can t be invoked as external programs. Most internal commands are, however, also pro- vided as standalone programs this requirement is part of the POSIX specification. It generally doesn tmatter if the command is internal or external, except that internal commands execute more efficiently. Here we ll cover only the main commands, both internal and external, that we use when we re program- ming scripts. As a Linux user, you probably know many other commands that are valid at the commandprompt. Always remember that you can use any of these in a script in addition to the built-in commandswe present here. breakWe use this for escaping from an enclosing for, while, or untilloop before the controlling conditionhas been met. You can give breakan additional numeric parameter, which is the number of loops tobreak out of. This can make scripts very hard to read, so we don t suggest you use it. By default, breakescapes a single level. #!/bin/shrm -rf fred* echo > fred1echo > fred2mkdir fred3echo > fred450Chapter