Final - Chapter 6 Flashcards

1
Q
  1. Your organization routinely uses scripts, but as some employees have left, there are scripts that contain only command lines and no one is certain of their purpose.

What steps can be taken to ensure a way for others to know the purpose of a script?

A

Require that script writers place comment lines inside the scripts using the # symbol
to begin each comment line.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Which of the following shells enables the use of scripts? (Choose all that apply.)
    a. Bash
    b. csh
    c. sea
    d. zsh
A

A,B,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. You frequently use the command ls -a and want to save time by just entering l to do
    the same thing.Which of the following commands enables you to set your system to
    view hidden files by only entering l ?
    a. put l= ls -a
    b. set l to ls -a
    c. set “ ls -a” to “l”
    d. alias l=” ls -a”
A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. You have written a script, but when you run it there is an error.Which of the following
    commands can you use to debug your script? (Choose all that apply.)
    a. debug -all
    b. sh -v
    c. ./ -d
    d. sh -x
A

B and D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. You have written a shell program that creates four temporary files.Which of the following
    commands can you use to remove these files when the script has completed
    its work?
    a. trap
    b. grep
    c. del
    d. clear
A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
6. Which of the following commands works well for menus used in a script? (Choose
all that apply.)
a. do
b. case
c. choose
d. comm
A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. You are currently in the source directory, which is the new directory you have just
    created for storing and running your scripts.You want to make certain that the
    source directory is in your default path.Which of the following commands enables
    you to view the current default path settings?
    a. cat PATH
    b. show path
    c. sed PATH!
    d. echo $PATH
A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. You have created a script for use by your entire department in a commonly accessed
    directory. Only you are able to run the script, which works perfectly.Which of the
    following is likely to be the problem?
    a. You did not link the script.
    b. You did not give all users in your department execute permission for that script.
    c. You did not designate to share ownership of the script.
    d. There are two kinds of scripts, universal and private.You have created a private script
    and need to convert it to universal.
A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. Your current working directory contains a series of files that start with the word
    “account” combined with a, b, c, d, and e, such as accounta, accountb, and so on.
    Which of the following commands enables you to view the contents of all of these
    files? (Choose all that apply.)
    a. ls account “a -e”
    b. less account “a,e”
    c. more account[ a,b,c,d,e ]
    d. cat account{a to e}
A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. For which of the following logic structures used within a script is fi the final line for
    that logic structure? (Choose all that apply.)
    a. loop
    b. case
    c. for
    d. if
A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
11. Which of the following are examples of arithmetic or relational operators? (Choose
all that apply.)
a. !
b. <
c. %
d. *
A

All of Them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. You have created a series of scripts that use the same environment variables. However, when you run these scripts, some of them do not seem to recognize the environment variables you have set. What is the problem?
A

You need to use the export command so these variables have global use.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. You have spent the last two hours creating a report in a file and afterwards you use cat to create a new file.

Unfortunately the new file name you used was the same as the name you used for the report, and now your report is gone.

What should you do next time to prevent this from happening?

A

Enter the command, set -o noclobber before you start.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. You have remotely logged into a computer running UNIX or Linux, but you are not certain about which operating system you are using. However, when you display the contents of the variable it shows which operating system you are using.
    a. OP
    b. OPTIND
    c. OID
    d. OSTYPE
A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. What command can you use to view the environment and configuration variables already configured on your system?
    a. var
    b. envar
    c. printenv
    d. let -all
A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  1. Which of the following are valid expressions? (Choose all that apply.)
    a. let x=5*9
    b. let x=y+10
    c. let m=12/4
    d. let r=128-80
A

ALL

17
Q
  1. When you type for wood maple spruce oak pine at the command line and then press Enter, what should you type next at the > prompt?
    a. do
    b. go
    c. fi
    d. Term
A

A

18
Q
  1. You want to store a long listing of your files in a variable called myfiles.Which of the
    following commands enables you to do this?
    a. let ls -l=myfiles
    b. echo ls -l > myfiles
    c. myfiles=‘ls -l‘
    d. let ls -l > myfiles
A

C

19
Q
  1. What error is in the following script code?
case “selection” in
“ i ”) ./listscript ;;
“ ii ”) ./numberscript ;;
“ iii ”) ./findscript ;;
esac
A

There should be a dollar sign in front of selection, as in “$selection”

20
Q
  1. You are working with a colleague on a script called value that updates several files.

You want to test the script, but not update the files. Which of the following commands can you use?

a. test -noupdate value
b. trap -u value
c. set -u value
d. sh -n value

A

D

21
Q
  1. You only have to enter the name of a script to have it run, such as entering myscript. What setting enables you to do this?
A

You have placed the directory from which you run the scripts in your PATH
variable.

22
Q
  1. What would you expect to find in the HOME environment variable?
A

absolute path to user’s home directory

23
Q
  1. What is the difference between a compiler and an interpreter?
A

compiler converts the code into machine language in a separate file. An interpreter takes commands or code to run on the spot.

24
Q
  1. What command would you use to place the cursor in row 10 and column 15 on the screen or in a terminal window?
A

tput cup 10 15

25
Q
  1. What is the purpose of a login script?
A

The login script:

  1. runs each time you log into your account.
  2. can include commands, such as aliases and the set -o noclobber command, that take effect as soon as the script runs and that last for the duration of the login session.
26
Q
  1. You should omit spaces when you assign a variable without using single or double quotation marks around its value.(T/F)
A

True

27
Q
  1. The ____ shell, when compared to the other shells, has a more powerful programming interface.
A

Bash

28
Q
  1. A program’s high-level language statements are stored in a file called the ____ file.
A

Source

29
Q
  1. The ____ statement simplifies the selection of a match when you have a list of choices.
A

Case

30
Q

30.

A ____ is a name consisting of letters, numbers, or characters and is used to reference the contents of a variable.

A

Symbolic Name

31
Q
  1. The ____ command is useful when you want your shell program to automatically remove any temporary files that are created when the shell script runs.
A

Trap

32
Q

32.

You use the chexec command to indicate that a (shell script) file can be executed.(T/F)

A

False

33
Q
  1. ____ gives the owner read, write, and execute permissions.
A

Chmod 755

34
Q
  1. Wildcard characters are also known as ____ characters.
A

glob