Chapter 7 - Advanced Shell Programming

Ace your homework & exams now with Quizwiz!

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

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.)

You can load the file's functions into memory by entering .filetests && This is a hidden file

What does a down arrow represent in a flowchart?

process flow

Each month your business manually deletes specific records for employees who have left the company.You have been asked to write a script to automate this process. Which of the following commands works well for deleting records in a file?

sed -d

Create a statement that enables you to determine if the file /source/results is newer than the file /data/results

stringtest( ) { test -z $text echo $? }

What symbol is typically used at the start and end of a flowchart?

terminator

Which of the following statements enables you to determine if the variable, called value, is less than 750?

test $value - lt 750

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?

test -w clients

Create a simple function that determines if the string variable, text, contains no characters (is of zero length).

test/source/results -nt/data/results test/source/results -nt /data/results ; echo $?

Which of the following script statements accomplishes the same thing as the statement: while [ "$part" != "alternator" ] ; do ? (Choose all that apply.)

while test $part != "alternator" ; do

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?

write pseudocode before you create the actual script

When you create a shell function from the command line, what character do you enter at the first > prompt just after you declare the function's name?

{

Which of the following characters are placed right after a function name when you create a shell function?

( )

Which of the following are examples of Boolean operators used with the test command? (Choose all that apply.)

-a for a logical AND -o for a logical OR

Some Linux systems use the ___________ script to perform the same actions each time a user logs out of her account

.bash_logout

In your organization everyone uses the Bash shell in Red Hat Enterprise Linux and all users use the same aliases and shell functions. In what file or files can the system administrator place these aliases and functions so they are available to all users?

/etc/.bashrc /etc/profile

In which of the following files would a system administrator set the default shell used by your account?

/etc/password

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?

CLR = `clear`

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

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?

Load them via your login script

What is an exit status and with what command is it used?

The exit status is used with the test command and is a value that represents the value of a test, such a value of 0 to show that the results of the test are true or a value of 1 to show the test results are false.

When you enter test -d tmp ; echo $?, you see a 0 displayed on the screen.What does this mean?

The tmp directory exists

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?

cat customers | tr "^" ":"

Which of the following are examples of symbols you might use in a flowchart? (Choose all that apply.)

decision document magnetic diskdata

When working on the script in Question 15, which of the following should you consider?

input validation


Related study sets

Physics Unit 9: Force and Motion

View Set

Fundamentals- managing client care

View Set

Most Missed Questions from Behavioral Psychology and Consciousness

View Set