In: Computer Science
1. You have just finished a 25-page paper that you have written using Emacs.The file containing the paper is called /assignments/data_sources.After your instructor has briefly looked at the paper, she recommends that you change all instances of the ref- erence “data is” to “data are” before you submit it.Which of the following com- mands can you use to locate these references in the file for a quick assessment of how much you have to change?
a. find - i 'data is' /assignments/data_sources
b. test /assignments/data_sources "data is"
c. grep "data is" /assignments/data_sources
d. scan -t data is /assignments/data_sources
2. You are interested in determining the number of words in your /assignments/ data_sources file mentioned in Question 1.Which of the following commands should you use?
a. wc -w /assignments/data_sources
b. wc -m /assignments/data_sources
c. counter /assignments/data_sources
d. counter -c /assignments/data_sources
3. Which of the following are examples of manipulation and transformation commands? (Choose all that apply.)
a. sed
b. pr
c. join
d. Paste
4. Which of the following is true of the pipe operator? (Choose all that apply.)
a. Only one pipe operator can be used on a single command line.
b. It is used to perform division on the results of a numerical command operator.
c. It is used instead of the colon (:) for entering multiple commands
d. It redirects the output of one command to the input of another command.
5. Because the data was formatted the same in two inventory files, you decided to com- bine their contents into one file. Now you want to determine if there are duplicate entries on consecutive lines in the new file.Which of the following commands enables you to find the duplicate entries?
a. dup
b. pr
c. uniq
d. Cat
6. Your friend is using the command comm entryfile, but is getting an error message. What is the problem? (Choose all that apply.)
a. entryfile contains only numbers, but the comm command must be used on a file with text.
b. It is necessary to use either the -m or -t option with the comm command.
c. entryfile is too long, because the comm command can only be used on a file under
100 KB in size.
d. It is necessary to specify two files when you use the comm command.
7. Your boss is trying to import the customers file into her spreadsheet program, but the data goes into the spreadsheet incorrectly.This is because the fields are separated by dashes (-) and the spreadsheet program requires the fields to be separated by colons (:).Which of the following commands can you use to convert the
customers file?
a. replace - : customers
b. tr "-" ":" < customers
c. sed %- %: > customers
d. cat -r -/: customers
8. How can you link multiple files to manipulate the data in those files?
a. with a linker
b. with a project field
c. with a common or key field
d. with an operator entry
9. While in the Bash shell, you have written a simple script file and now want to execute the script.Which of the following commands enables you to run the script?
a. sh
b. go
c. ex
d. !!
10. You are using the grep command, but it is only searching through files in your imme- diate home directory.What option enables you to search through subdirectories below your home directory?
a. -s
b. --sub
c. -c
d. -r
11. Your software has a bug in that it enables you to create a vendors file in which there are duplicate entries of vendors.Which of the following methods enables you to remove the duplicate vendors in this text file?
a. Sortthefileandthenusethecommcommandtoremovetheduplicates,inputtingthe result into the same file.
b. Sort the file in reverse order and then use the dump command to remove the duplicates.
c. Sort the file and then use the uniq command to remove the duplicates, inputting the result in a new file.
d. Reverse sort the file, use the join command, and output the results back into the vendors file.
12. Each time you list the files in your home directory, the output scrolls by so fast you can’t read it.Which of the following enables you to view the output one screen at a time?
a. cat -pause
b. ls -l | more
c. window ls -a
d. dir < display
13. You are creating a file to send over the Internet via a satellite connection that only allows you to send files under 250 KB.Which of the following commands enables you to determine the number of bytes in the file before you try to send it?
a. cat -s
b. tr -b
c. counter -k
d. wc -c
14. In the command sed -f fixit notes > instructions, what is “fixit”?
a. a script file
b. an operator
c. a function
d. a formatting interpreter
15. When you design a record layout, you should do which of the following? (Choose all that apply.)
a. identify each field by data type
b. plan to delimit fields using a dash
c. identify each field by name
d. store only fields relevant to the record’s purpose
16. What sed command option enables you to append new text to a file?
a. p
b. -n
c. a\
d. |add
17. Your boss has two salary scale files, salary and salary1, and wants to compare their contents side by side to see if there are any differences in the files.Which of the fol- lowing commands should he use?
a. diff -S salary > salary1
b. comm salary salary1
c. uniq salary < salary1
d. sed --comp salary salary1
18. When you use the pr command how can you limit the output to only a screen full of text to view. (Choose all that apply.)
a. Maximize your terminal window to hold 24 lines.
b. Pipe the output into more.
c. Use the -l 23 option.
d. Pipe the less command into the more command.
19. When you use the Awk printf capability, what does the dollar sign ($) represent?
a. a field size limit
b. a multiplier
c. a command to put text in lowercase
d. a data field
20. Your boss is trying to delete the word “difficult” as it appears in a text file containing his speech about motivation.The name of the file is motivate.When he decides to use the tr command to delete this word, it instead deletes characters throughout the text.Which of the following commands is he likely to have used?
a. tr -d "difficult" < motivate
b. tr difficult motivate
c. tr -o 'difficult' > motivate
d. tr --eliminate difficult motivate
21. When you enter the command grep Linux /info/Linux_ features | head, what is the maximum number of lines that will be displayed?
a. 24 lines
b. 23 lines
c. 15 lines
d. 10 lines
22. List four examples of selection commands.
23. What is the general format for using the pipe operator?
24. Briefly explain what you can accomplish with the sed command.
25. You want to create a file of your friends’ and relatives’ names, addresses, telephone numbers, and other information.When you mention this to your sister-in-law, she recommends having separate fields for the first, middle, and last names. Briefly explain why this is a good idea.
1. c grep "data is" /assignments/data_sources
Grep searches for lines containing a specified pattern and, by default
3. All of the options as all are manipulative and transformative in some form
join - join lines of two files on a common field
sed - stream editor for filtering and transforming text
pr - convert text files for printing
paste - merge lines of files
4.The pipe operator ( | ) redirects the output of one command to the input of another command.It may consist of multiple commands.
• Multiple pipe operators can be used on a single command line. Hence, the option (a) is incorrect.
• There is no division on the results of a numerical command operator. Hence, the option (b) is incorrect.
• Even multiple commands the operator (|) is not change. Hence, the option (c) is incorrect.
5. C uniq
uniq - report or omit repeated lines
6 d- It is necessary to specify two files when you use the comm command.
The comm command compares lines common to the two sorted files.
It shows an error if it operates with a single file.
Thus, it is necessary to specify two files when you use the comm command.
8- c-Link multiple files to manipulate the data in those files using with a common or key field.
• With a linker is not a valid command. So, option (a) is incorrect.
• With a project field, link multiple files to manipulate the data in those files is not possible. Hence, the option (b) is incorrect.
• With an operator entry, link multiple files to manipulate the data in those files is not possible. Hence, the option (d) is incorrect.