How would you write a test that says if /tmp/foo is a directory or USERS is greater than 5? How would you write a test that says if /tmp/foo is a directory or USERS is greater than 5? Answer - test -d /tmp/foo -o $USERS -gt 5
What is the meaning of $(( $i + 1)) ? What is the meaning of $(( $i + 1)) ? Answer: 1 will be added to the i variable
A conditional that lets you make multiple comparisons with a pattern is called: A conditional that lets you make multiple comparisons with a pattern is called: Answer: case
The if command looks for what exit code to consider a condition to be true? The if command looks for what exit code to consider a condition to be true? Answer: 0
Given the following script that is run through ./test.sh hello goodbye: Given the following script that is run through ./test.sh hello goodbye: Answer: if [ -f $2 ]; then echo "I am here" fi When will I am here be printed? If a file called "goodbye" exists in the current directory
Which of the following are correct about for and while loops? Which of the following are correct about for and while loops? Answer: - for loops operate over a fixed list of items - while loops have a test each cycle to determine if it should run again
What does this shell script do? What does this shell script do? Answer: FOO=/tmp/foo if [ ! d $FOO ]; then mkdir $FOO fi Creates /tmp/foo if it does not exist
A file begins with #!/bin/csh. This means: A file begins with #!/bin/csh. This means: Answer: Running the script will invoke /bin/csh to interpret the rest of the file
The command echo "text" >> file.txt will not overwrite file.txt if it already exists. The command echo "text" >> file.txt will not overwrite file.txt if it already exists. Answer: True
The command echo "text" > file.txt will create file.txt if it does not already exist. The command echo "text" > file.txt will create file.txt if it does not already exist. Answer: True
Which option for the wc command will print the number of lines in a file? Which option for the wc command will print the number of lines in a file? Answer: -l
Which of the following commands scans the file to determine file locations? Which of the following commands scans the file to determine file locations? Answer: find
Which of the following commands can be used to scroll through a text file? Which of the following commands can be used to scroll through a text file? Answer: - more - less
Which of the following commands will display lines that contain either start or end? Which of the following commands will display lines that contain either start or end? Answer: egrep 'start|end' file.txt
Which of the following commands will display only lines that begin with test? Which of the following commands will display only lines that begin with test? Answer: grep ^test file.txt
The grep command... The grep command... Answer: ...will display all the lines in a file containing the specified Regular Expression.
Which option of the head command will display only the first five lines of a file? Which option of the head command will display only the first five lines of a file? Answer: -n 5
Which two commands do the same thing? Which two commands do the same thing? Answer: - tar c foo | gzip > foo.tar.gz - tar czf foo.tar.gz foo