In this chapter, we examined how to create shell initialization scripts, by examining how to set environment variables and execute commonly used script commands. In addition, we reviewed some basic shell script patterns, which can be used within .profile (and other shell scripts) to perform a wide variety of repetitive actions.
1. |
What is the name of the Bourne shell initialization script?
|
|
2. |
What is the name of the site-wide skeleton file for the Bourne shell initialization file?
|
|
3. |
What command would be used to set the value of the environment variable TERM to be vt220?”
|
|
4. |
What escape string is used to print an ASCII beep character in a shell prompt?
|
|
5. |
What escape string is used to print a date string in a shell prompt?
|
|
6. |
What escape string is used to print the full hostname in a shell prompt?
|
|
7. |
What escape string is used to print a short hostname in a shell prompt?
|
|
8. |
What command is used to source another shell script while maintaining all environment settings?
|
|
9. |
What command would be used to display the string “Status OK” while .profile was being executed during shell initialization?
|
|
10. |
What parameter is used with the test command to determine whether a file is a special block file?
|
|
Answers
1. |
C. The name of the Bourne shell initialization script is .profile. |
2. |
C. The name of the site-wide skeleton file for the Bourne shell initialization file is /etc/skel/local.profile. |
3. |
A. TERM=vt220 will set the environment variable for the terminal type to vt220. |
4. |
A. The ASCII beep character is \a. |
5. |
B. The date string is represented by \d. |
6. |
D. The shell prompt is set by \H. |
7. |
C. The short hostname is represented by \h. |
8. |
C. The source command is “.". |
9. |
C. The command echo "Status OK" will display the "Status OK" string. |
10. |
A. The –b option is used to test for special block files. |