Final - Chapter 7 Flashcards
- You have been asked to write a script for use by the faculty at the engineering
school at your college.
The script you write uses the Bash shell, but some faculty members often use a different shell in their work.
How can you best ensure that the Bash shell is invoked when this script is run?
Enter the line # !/ bin/bash as the first line in the script.
- Which of the following script statements accomplishes the same thing as the
statement: while [ “$part” != “alternator” ] ; do ? (Choose all that apply.)
a. while $part “alternator” ; do
d. test $part -eq “alternator” | do
B
- Your shell script, called .filetests, contains several functions used to run tests on files, such as to determine if a file is empty or has the correct permissions.
Which of the following is/are true about .filetests? (Choose all that apply.)
a. You can load the file’s functions into memory by entering . .filetests.
b. This is a hidden file.
c. You can run the functions in the file by entering !. filetests.
d. This is a character special file.
A and B
- When you enter echo $CLR your screen clears very quickly.Which of the following
commands must you have entered previously to enable use of echo $CLR to clear the
screen?
a. set =:clear
b. let clear=CLR
c. $clear=CLR
d. CLR=‘clear‘
D
- Your company has assigned you to revise 22 scripts. Since you use the vi editor, how can you set it to automatically display lines as numbered so it is easier for you to work on these revisions?
Create the .exrc file in your home directory so this file contains the line: set number.
- You use the same five shell functions every day and are looking for a way to ensure they are available as soon as you log into your account.What can you do?
a. Make them residual system variables.
b. Make them permanent environment variables.
c. Load them via your login script.
d. Make them permanent functions by adding them to the /func directory.
C
7. When you enter test -d tmp ; echo $?, you see a 0 displayed on the screen.What does this mean? a. The tmp file is empty. b. The tmp file contains over 1 MB. c. The tmp directory exists. d. The tmp directory is empty.
C
- What does a down arrow represent in a flowchart?
a. process flow
b. manual input
c. stored data
d. display
A
- Which of the following are examples of Boolean operators used with the test
command? (Choose all that apply.)
a. -a for a logical AND
b. -m for a partial MERGE
c. -n for logical NEGATION
d. -o for a logical OR
A, C, D
- You have a specialized data file, called customers, in which the fields in the file are separated by the character ^.
You want to view this file with a colon between the fields before you convert it to remove the ^ characters and insert colons. Which of the following commands enables you to view the file in this way?
a. insert -t : ^ | customers
b. test - i [^] [:] customers
c. cat customers | tr “^” “:”
d. sub ‘:’ ‘^’ > customers
C
11. Which of the following statements enables you to determine if the variable, called value, is less than 750? a. echo $value -l 750 b. comm value$ to 750 c. test $value - lt 750 d. test "value" >! 750
C
- Some Linux systems use the script to perform the same actions
each time a user logs out of her account.
a. .bash_logout
b. .bash_rc
c. /bin/bashout
d. /etc/logoff_bash
A
- You have recently met with your company’s budget committee about creating a script to for producing the same budget reports at the end of each month.
Because this is an important undertaking you’ve started by creating a flowchart.
What step should you take next?
a. Immediately write the functions you’ll need for the script.
b. Create a menu script.
c. Find the three most important fields in the Budget file that you can use as keys
d. Write pseudocode before you create the actual script.
D
14. Which of the following are examples of symbols you might use in a flowchart? (Choose all that apply.) a. decision b. document c. data d. magnetic disk
ALL
- The script you are creating takes data input to use for updating a file. Before taking the data input, you want the script to verify that the file to be updated, called clients, exists and that the script user has permission to write to that file.Which of the following statements enables you to do this?
a. string -w clients
b. test -w clients
c. chmod -all clients
d. tr -ew clients
B