Dcom 142 Final Questions With Verified Answers
Which keystrokes invoke the pico or nano search function? - Answer F6 Ctrl-W Three keystrokes that can initiate a search-and-replace operation in nano are F14, , and . - Answer Ctrl+ Esc+R For which type of file is nano least likely to be useful for examining or editing? - Answer A LibreOffice word processing document While in vi's command mode, you can type to undo a change. - Answer u To save a file and exit the vi text editor in command mode, type - Answer ZZ If you have never used a text editor before, the nano text editor is usually the best one to learn first. - Answer True ASCII supports unique characters(not including control characters.) - Answer 128 GUI text editors for ASCII are superior to text-mode ASCII text editors because the GUI editors support underlining, italics, and multiple fonts. - Answer False Unicode is useful for encoding most European languages but not not Asian languages. - Answer False How would you remove two lines of text from a file when using vi? - Answer In command mode, position the cursor on the first line and type 2dd. What is the name of the software that we downloaded. - Answer Wingide 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 A conditional that lets you make multiple comparisons with a pattern is called: - Answer case A file begins with #!/bin/csh. This means: - Answer Running the script will invoke /bin/csh to interpret the rest of the file Most of nano's commands take the form of: - Answer Control and another character How would you finish your script with an exit code of 42? - Answer exit 42 Given the following script that is run through ./ hello goodbye: if [ -f $2 ]; then echo "I am here" fi When will "I am here" be printed? - Answer If a file called "goodbye" exists in the current directory The number of users logged in is in a variable called USERS. How would you test to see if 5 users are logged in? - Answer test $USERS -eq 5 What does this shell script do? FOO=/tmp/foo if [ ! -d $FOO ]; then mkdir $FOO fi - Answer Creates /tmp/foo if it does not exist Which shell command accepts input from the user's keyboard? - Answer read The if command looks for what exit code to consider a condition to be true? - Answer 0 What is the correct way to assign the word "Hello" to a variable? - Answer . A="Hello" Which of the following are correct about for and while loops? (choose two - Answer while loops have a test each cycle to determine if it should run again for loops operate over a fixed list of items Given the following part of a script: if [ -f $1 ]; then echo "I am here" fi What is the meaning of $1? - Answer It is the first argument passed to the script What information is held inside $? ? - Answer The previous command's exit code What is the meaning of $(( $i + 1)) ? - Answer 1 will be added to the i variable What is the correct way to save the current directory to a variable? - Answer A=`pwd` The echo command: - Answer Is used to output text to the console Which are appropriate editors for writing shell scripts? (choose two) - Answer nano vi Given the following script: while [ ! -f /tmp/foo ]; do echo -n "."
Document information
- Uploaded on
- November 8, 2023
- Number of pages
- 14
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers