Chapter 07 Working with the Shell

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

You have redirected stderr to a file called Errors. You view the contents of this file afterward and notice that there are six error messages. After repeating the procedure, you notice that there are only two error messages in this file. Why?

You did not append the stderr to the Error file, and, as a result, it was overwritten when the command was run a second time.

Which of the following lines can be used to perform command substitution within a shell script? (Choose all that apply.)

`command`, $(command)

Which of the following will display the message welcome home if the cd /home/user1 command is successfully executed?

a. cd /home/user1 && echo "welcome home"

Which construct can be used in a shell script to read stdin and place it in a variable?

a. read

Before a user-defined variable can be used by processes that run in subshells, that variable must be _____.

exported

Every if construct begins with if and must be terminated with _____.

fi

Which command could you use to see a list of all environment and user-defined shell variables as well as their current values?

set

Which of the following variables could access the value "/etc" within the sample shell script, if the sample shell script was executed using the bash sample /var /etc /bin command?

$2

Consider the following shell script:echo -e "What is your favorite color?--> \c"read REPLYif [ "$REPLY" = "red" -o "$REPLY" = "blue" ]thenecho "The answer is red or blue."elseecho "The answer is not red nor blue."FiWhat would be displayed if a user executes this shell script and answers Blue when prompted?

. The answer is not red nor blue.

Which of the following files is always executed immediately after any user logs in to a Linux system and receives a BASH shell?

/etc/profile

Because stderr and stdout represent the results of a command and stdin represents the input required for a command, only stderr and stdout can be redirected to/from a file.

False

What does &> accomplish when entered on the command line after a command?

It redirects stderr and stdout to the same location.

A user attempts to perform the git commit -m "Added listdir function" but the command fails. What are possible reasons for the failure? (Choose all that apply.)

The user performing the commit has not set their Git user information No files were added to the Git index beforehand. The user performing the commit is not running the command from within the Git repo directory.

A for construct is a loop construct that processes a specified list of objects. As a result, it is executed as long as there are remaining objects to process.

True

Both aliases and functions can be used to store commands that can be executed, but functions can also accept positional parameters.

True

The sed and awk commands are filter commands commonly used to format data within a pipe.

True

The current value for the HOME variable is displayed by which of the following commands? (Choose all that apply.)

b. echo ~, c. echo $HOME

What would be the effect of using the alias command to make an alias for the date command named cat in honor of your favorite pet?

c. When you use the cat command at the command prompt with the intention of viewing a text file, the date appears instead

Which of the following operators reverses the meaning of a test statement?

d. !

How do you indicate a comment line in a shell script?

d. Begin the line with #.


Kaugnay na mga set ng pag-aaral

chapter 09. Elections Inquizitive

View Set

Nursing Fundamentals Chapter 23.

View Set

asdfasdfasdf, Comm 102 review, com-120 final (chp. 8 - chp. 12), Interpersonal Communication Exam 3, Chapter 11: Attraction and Intimacy, COMST 218, Communications Final Chapter 11, Chapter 13 Knowledge Check, Ch 9-12, ch.12 communication climate, Ch...

View Set

VWL - 4 Der Markt schlägt zurück

View Set