Exercises stores the complete set of positional parameters as a single string
4. a. When you are writing many shell scripts, it can get tedious to give many chmod commands. This function speeds up the process.
b. $ function perms {
> chmod u+x $*
> }
c. Put the function in your .bash_profile, .bash_login, or .profile file to make it available each time you run a log in (using bash).
d. Use source to execute the file you put the function in, i.e.
$ source .bash_profile
5. A shell function will do nothing unless it is explicitly called by other code A shell script is a runnable, executable process, which can call other shell scripts and/or functions.
The question might be worded backwards - it is necessary to write shell functions for shell scripts when certain logical functionality is required to be performed multiple times - they operate the same way. 6. $ cat listdirs file "$@" | grep directory | sed 's/:.*//'. 9. a. #!/bin/bash plus1 () { echo $(($1 + 1)); } echo $(plus1 8) export -f plus1
./child 14 21 b. Each Name the full file name of the command is determined by searching the directories in $PATH and remembered.
c. If command is not specified, a non-interactive shell exits, unless the shell option exefail is enabled, in which case if returns failure. Returns if file cannot be executed.
Exercises
1. -w option on the command line 2. Array is an order list of values position by index. Hash is an unordered list of values position by keys.
5. ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0- 9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"