| 9. || |
Write a sequence of commands or a script that demonstrates that variable expansion occurs before pathname expansion.
| 10. || |
Write a shell script that outputs the name of the shell that is executing it.
| 11. || |
Explain the behavior of the following shell script:
$ cat quote_demo twoliner="This is line 1.
This is line 2."
How many arguments does each echo command see in this script? Explain.
Redefine the IFS shell variable so that the output of the second echo is the same as the first.
| 12. || |
Add the exit status of the previous command to your prompt so that it behaves similarly to the following:
$  ls xxx ls: xxx: No such file or directory
| 13. || |
The dirname utility treats its argument as a pathname and writes to standard output the path prefixthat is, everything up to but not including the last component:
$ dirname a/b/c/d a/b/c
If you give dirname a simple filename (no / characters ) as an argument, dirname writes a . to standard output:
$ dirname simple .
Implement dirname as a bash function. Make sure that it behaves sensibly when given such arguments as / .
| 14. || |
Implement the basename utility, which writes the last component of its pathname argument to standard output, as a bash function. For example, given the pathname a/b/c/d , basename writes d to standard output:
$ basename a/b/c/d d
| 15. || |
The Linux basename utility has an optional second argument. If you give the command basename path suffix , basename removes the suffix and the prefix from path :
$ basename src/shellfiles/prog.bash .bash prog
$ basename src/shellfiles/prog.bash .c prog.bash
Add this feature to the function you wrote for exercise 14.