UNIX Ch 7

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following will the split command do on a file when no other options are specified? a. It will split a file into new equally sized files that are 1/10th of the original file size. b. It will split a file into new files that are 1,000 lines each. c. It will split a file into new files that are 1 megabyte each. d. It will split a file into new files that are 1 kilobyte each.

It will split a file into new equally sized files that are 1/10th of the original file size.

Which of the following is the common escape sequence to display a horizontal tab using the echo command? a. \tab b. ?tab c. %tab d. \t

\t

Which of the following results would be created by the command sequence: echo 'apple banana carrot dog elephant' | while read a b c; do echo result: $c $b $a; done a. carrot dog elephant apple banana b. apple banana carrot dog elephant c. elephant dog carrot d. carrot dog elephant banana apple

carrot dog elephant banana apple

Which of the following commands will send the output of the cat command to the grep command to be filtered? a. cat /etc/passwd @ grep jsmith b. cat /etc/passwd > grep jsmith c. cat /etc/passwd | grep jsmith d. cat /etc/passwd >> grep jsmith

cat /etc/passwd | grep jsmith

Which of the following commands will display the exit status of the last command used in the BASH shell? a. echo $status b. echo $! c. echo $exit d. echo $?

echo $?

Which command can be used to download an updated copy of the master branch from the original Git repository? a. git pull original master b. git pull origin master c. git pull master original d. git pull master origin

git pull origin master

Which of the following files can you add filenames to so that the git add * command will not stage them? a. .nopush b. .gitnopush c. .gitignore d. .ignore

gitignore

Which of the following commands will count down from 10 to 1? a. seq 10 1 b. seq 10 -1 c. seq 10 -1 1 d. seq 10 1 -1

seq 10 -1 1

How many times will the following loop execute as part of a script: #!/bin/bash COUNTER=0 while [ $COUNTER -lt 7 ] do echo "hello world" done

until ctrl-c is used to terminate it (b/c there's no update statement to update counter so this is infinite loop)

Which of the following commands will count the number of lines in a file named data.csv? a. wc -l data.csv b. lines data.csv c. count -l data.csv d. lc data.csv

wc -l data.csv

Using the syntax below, what command will create directories named one, two, and three? ​ echo one two three | ___________ mkdir

xargs

Which of the following would be the results of running the command seq 7? a. 0 through 6 being displayed one number per line. b. 6 through 0 being displayed one number per line. c. 7 through 1 being displayed one number per line. d. 1 through 7 being displayed one number per line.

1 through 7 being displayed one number per line.

Which of the following constructs can be used in a shell script to determine whether two values are equal and if so run another set of commands? a. comp b. where c. if d. when

if

An alias has previously been created named showauth. Which of the following commands can be used to get rid of that alias? a. noalias showauth b. alias -d showauth c. ualias shoauth d. unalias showauth

unalias showauth

Which of the following characters can be entered at the beginning of a line in a shell script to ensure that line is recognized as a comment rather than try to execute it? a. # b. > c. $ d. %

#

Which of the following represents stderr at the command line when used for redirection? a. 1 b. 0 c. 3 d. 2

2

Which of the following can be used for comparing values within an if statement? (Choose two.) a. = b. -lt c. -neq d. -grt

= -lt

Which of the following will take output from a command and append it to the end of a file? a. >> b. < c. << d. >

>>

Which of the following commands can be used to create a BASH variable named CREATOR with the value of Torvalds? a. set $CREATOR = "Torvalds" b. CREATOR="Torvalds" c. var CREATOR as "Torvalds" d. CREATOR = "Torvalds"

CREATOR="Torvalds" (no spaces)

Levi wants to run 5 commands sequentially, but does not want to create a shell script. He knows that each command is going to take approximately 20 minutes to run individually. However, he would like to go to lunch 15 minutes from now. He knows that he can type all of the commands on the same line and separate them with a certain character to run them sequentially. Which character can he type after each command to have them run one after the next without requiring further input from him? a. a comma b. a semicolon c. a pound sign d. a colon

a semicolon

Which command can be used to create a new command that will monitor the contents of auth.log as they get added to the file? a. alias showauth='tail -f /var/log/auth.log' b. ln showauth='tail -f /var/log/auth.log' c. new showauth as 'cat -f /var/log/auth.log' d. create showauth='tail -f /var/log/auth.log'

alias showauth='tail -f /var/log/auth.log'

You have just created a variable named CREATOR. Which of the following commands will display the contents of the variable to standard output? a. echo $CREATOR b. print CREATOR c. echo CREATOR d. disp $CREATOR

echo $CREATOR

When writing shell scripts and using an if statement to determine whether a set of code should be executed, what is the proper syntax to end the if construct? ___________

fi

Which of the following commands should you use to specify that you want to use Git for version tracking on them? a. git track b. git add c. git version d. git new

git add

Which of the following will look at the /etc/passwd file for any lines containing the word root and display them out to the screen while simultaneously writing the results to a file? a. grep root /etc/passwd | tee ~/root.txt b. grep root /etc/passwd | split ~/root.txt c. cat /etc/passwd | grep root >> ~/root.txt d. cat /etc/passwd | grep root | merge ~/root.txt

grep root /etc/passwd | tee ~/root.txt

The subdirectory newdir does not currently exist in the current directory that you are in. Which of the following commands will create a new directory named newdir and then change into that directory? (Choose two.) a. mkdir newdir && cd newdir b. mkdir newdir || cd newdir c. mkdir newdir; cd newdir d. mkdir newdir >> cd newdir

mkdir newdir && cd newdir mkdir newdir; cd newdir

Which of the following commands will display the output of a file while also displaying a line number at the left side of each line for the /etc/passwd file? a. ln /etc/passwd b. wc -l /etc/passwd c. numbers /etc/passwd d. nl /etc/passwd

nl /etc/passwd

Which of the following can be included in a shell script to ask the user to type in a password and then store it in the variable named $password? a. read -s -p "Please enter the password: " $password b. read -p -s "Please enter the password: " password c. read -p "Please enter the password: " $password d. read -s -p "Please enter the password: " password

read -s -p "Please enter the password: " password

Which of the following commands will display the contents of the /etc/passwd file in alphanumerical order? a. cat --sort /etc/passwd b. cat -s /etc/passwd c. sort /etc/passwd d. sed /etc/passwd

sort /etc/passwd

Which of the following is a valid method of running a script named myscript.sh? (Choose two) a. exec ./myscript.sh b. run myscript.sh c. source myscript.sh d. ./myscript.sh

source myscript.sh ./myscript.sh


Conjuntos de estudio relacionados

Chapter 2 Financial Statements, Taxes and Cash Flow

View Set

Agriculture, Industry, and Development Test Review HG

View Set

Peak by Roland Smith Vocab Definitions

View Set

Computer Science Paper 1 - Fundamentals of algorithms

View Set

Kingdom Classification of Biodiversity HL Biology Unit 5

View Set

Drugs Used to Treat Migraine Headaches

View Set