Chapter 4 Cumulative Review

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

this option prevents the touch command from creating a file, if it does not already exist

-c

The ____ option of the paste command is used to specify a different separator as a delimiter.

-d

When you use the paste command, columns of information are separated by a tab. However, your boss wants the columns separated by a colon. What option enables you to specify the colon as the separator?

-d

option of the cut command used to indicate that a specific character separates the fields

-d

option of the cp command that provides a warning before an existing file with the same name is overwritten

-i

The ____ option of the find command displays files that have been changed within the last n minutes.

-mmin n

The ____ option of the find command displays files that have been changed within the last n days.

-mtime n

is an option of the find command

-name

when deleting a directory with rm, this option is used to recursively delete its files and subdirectories

-r

The cp ____ option creates a symbolic link or name at the destination rather than a physical file.

-s

option of the sort command used to indicate that a specific character separates the fields

-t

option of the mv command that overwrites a destination file with the same name, if the source file is newer than the one in the destination

-u

Which of the following conditions must be met for you to combine two files using the join command?

. The two files must have a common field, such as last name

You want to combine two files, data07 and data08, into a file called data_all. Which of the following commands do you use?

. cat data07 data08 > data_all

To run the myscript shell script located in the current directory, you should enter: ____.

./myscript

You have created a script file called sum_report in your home directory and have made it executable. What command do you use to run the script?

./sum_report

You can use the ____ operator to redirect commands or program error messages from the screen to a file.

2>

. Create a command that sorts on the second field in the file addresses, and then writes the sorted results to the new file sorted_addresses.

: The command that can accomplish this is sort -k 2 addresses > sorted_addresses.

How would you perform the action in Discovery Exercise 7, but write the results to the file total_accounts?

: Type paste -d '/' accounts1 accounts2 accounts3 accounts4 > total_accounts and press Enter.

You are starting a new year and need to create ten empty files for your accounting system. Which of the following commands or operators enable you to quickly create these files? (Choose all that apply.)

>

can be used with cat to combine the contents of two files

>

How can you put the contents of each line of the product1 file side by side with the contents of the product2 file, but with only a dash in between instead of a tab?

Answer: Type paste -d- product1 product2 and press Enter

How can you use the touch command to create four new files called sum, datanew, results, and calcs (using one command line)?

At the command line type touch sum, datanew, results, and calcs and press Enter. Alternatively you could also enter touch sum ; touch datanew ; touch results ; touch calcs. (Consider giving extra credit to students who provide both as answers.)

You are trying to use the command sort -t: +5 datastore, but you get an error message each time you try it. How can you save the error message in a file called error, so you can e-mail the file to your computer support person?

Enter sort -t: +5 datastore 2> error.

When you are moving files, using the -o option with the mv command can be a good idea so that you don't unexpectedly overwrite a destination file with the same name.

False

Make a copy of the corp_phones2 file and call it testcorp. Next create a single-line command that enables you to cut characters in the fifth column of the testcorp file and paste them back to the first column in the same file? (Hint: Two good solutions exist, one in which you use a semicolon and one with more finesse in which you use a pipe character.)

For the solution with the semicolon, you create a temporary file in the process, such as t1 and type cut -c5 testcorp > t1 ; paste t1 testcorp and press Enter. For the more elegant solution type cut -c5 testcorp | paste - testcorp and press Enter

Change the awk script that you created earlier so that the column headings are "Vendor" and "Product" and the name of the report is "Vendor Data."

In the line of the script that reads { print "\t\tVendors and Products\n" }, change the words "Vendors and Products" to "Vendor Data" Next, in the line that reads, { print " Vendor Name\t\t\t Product Name\n" } delete "Name" in both instances.

After you create a script file, what are the next steps to run it?

Make the file executable by using the chmod command. Next, run the file by typing ./ plus the name of the file.

Create a command that enables you to copy all of the files in the spreadsheets directory to the accounts directory (when both directories are first-level directories under your home directory and you are currently in your home directory).

The command to use is cp spreadsheets/* accounts .

How can you create a file called history by using a redirection operator?

Type > history and press Enter.

Assume you have a subdirectory named datafiles directly under your current working directory. What command can you use to copy the data1 and data2 files from your current working directory to the datafiles directory?

Type cp data1 data2 datafiles and press Enter.

Back up the history file to the file history.bak.

Type cp history history.bak and press Enter

Create and use a command that displays only the last names and telephone numbers (omitting the area code) of people in the corp_phones2 file. Place a space between the telephone number and the last name.

Type cut -c5-7,9-13,14-25 corp_phones2 and press Enter

How can you use a command you have learned in this chapter to list the names of all users on your system? (Hint: Find out the name of the file in which user information is stored.)

Type cut -f1 -d: /etc/passwd and press Enter.

. Use the cut command to create a file called descriptions that contains only the product descriptions from the products file you created earlier in this chapter.

Type cut -f2 -d: products > descriptions and press Enter.

How can you find all files in your home directory that were modified in the last seven days

Type find /home/username -mtime -7 -print and press Enter.

Assume you have 10 subdirectories and you want to locate all files that end with the extension ".c". What command can you use to search all 10 of your subdirectories for this file?

Type find /home/username -name *.c and press Enter

What command enables you to find all empty files in your source directory?

Type find /home/username/source -size 0 and press Enter.

Sort the corp_phones1 file by the last four digits of the phone number.

Type sort -t: -k 3 corp_phones1 or sort -t: -k 3 -g corp_phones1and press Enter.

Wait one minute or more and then change the timestamp on the history file you just created.

Type touch history and press Enter.

Type who and press Enter to view a list of logged-in users, along with other information. Now use the who command (which you learned about in Chapter 1) with a command you learned in this chapter to view who is logged in, but to suppress all other information that normally accompanies the who command.

Type who | cut -d" " -f1 and press Enter.

Create the subdirectory mytest. Copy a file into your new subdirectory. Delete the mytest subdirectory and its contents using one command..

Use mkdir mytest to create the subdirectory. Use the cp command to copy a file into the new subdirectory. From the directory above the new subdirectory type rm -r mytest and press Enter.

You are worried about copying over an existing or newer file in another directory when you use the move command. What are your options in this situation?

Use the -i or -u options with the move command.

You play guitar and keep two files on your computer. One file, called strings, lists the different brands of strings you keep on hand. Another file, called music, lists the music books and scores you own. When you enter the command paste strings music, what happens?

You see two columns side-by-side on the screen. The left column lists the stings and the right column lists the music books.

Your boss asks you to create a professional-looking report from the contents of two files. Which of the following tools enables you to produce a polished report?

awk

Which of the following commands would you use to make a backup copy of the file AR2008?

cp AR2008 AR2008.bak

You are in your home directory and need to copy the file MemoRequest to a folder under your home directory called Memos. Which of the following commands do you use?

cp MemoRequest Memos

You are examining your addresses file, which contains the first and last names of people you know as well as their street address, city, state, zip code, and telephone number. You want to print a list of last names, which is field 1, and telephone numbers, which is field 7. Which of the following commands enables you to print this list?

cut -f1,7 addresses

You have a personnel file that contains the names, addresses, and telephone numbers of all employees. The first field in the personnel file is the employee number and the second field is the employee last name. The third field is the first name and middle initial. Because there are no employees with the same last name, you want to check the file by last name to make certain all employees are included. Which of the following commands should you use?

cut -f2 personnel

When you use cat to combine two files into a third file, the first line of the output contains the first line of the first file followed by the first line of the second file.

false

You have a lot of subdirectories under your home directory and know that you saved the file supplemental in one of them, but you are not sure which one. After you use cd to change to your home directory, which of the following commands enables you to search all of your subdirectories for the file?)

find -name suplemental

Which of the following are ways in which you can structure a record containing data? (Choose all that apply.)

fixed-length and d. variable-length

A sorting ____ is a field position within each line.

key

To redirect the list of the files in a directory to a file called homedir.list, you enter ____.

ls > homedir.list

Which of the following can be accomplished with the mv command?

move and rename a file

To move a file, you use the ____ command along with the source file name and destination name.

mv

combines files side by side

paste

Assume you have four files: accounts1, accounts2, accounts3, and accounts4. Write the paste command that combines these files and separates the fields on each line with a "/" character, displaying the results to the screen

paste -d '/' accounts1 accounts2 accounts3 accounts4 and press Enter

Character special files are used by input/output devices for communicating one character at a time, providing what is called ____ data.

raw

In UNIX/Linux, text files and binary files are considered to be ____ files.

regular

You need to delete 30 files that all start with the letters "customer," such as customer_accounts, customer_number, and so on. Which of the following commands enables you to quickly delete these files?

rm customer*

When you no longer need a directory, you can use command ____ to remove it.

rmdir

You are doing some "house cleaning" and want to delete several empty directories. Which of the following commands can you use?

rmdir

You keep a yearly record of the birds you've seen in your town. The name of the file is birds. The file contains the following fields name (field 1), markings (field 2), year(s) viewed (field 3), and location (field 4). You want to review the contents of the file, sorted by location. Which of the following commands do you use?

sort -k 4 birds

What command enables you to sort the contents of a file in reverse order?

sort -r

Which of the following commands can you use to sort the file vendor_name and display the results on the screen?

sort vendor_name

System administrators and programmers refer to standard input as ____.

stdin

Standard output is referred to as which of the following?

stdout

System administrators and programmers refer to standard output as ____.

stdout

The paste command normally sends its output to ____.

stdout

Your project team uses a group of the same files and tracks whether they are still in use by looking at the last modified date. You need to show that a series of files are still in use by changing the last modified date to today. What command do you use?

touch

Moving and renaming a file are essentially the same operation.

true

UNIX/Linux store data, such as letters, product records, or vendor reports, in flat ASCII files.

true


Ensembles d'études connexes

Psychosocial Theory of Human Development: Adult Development

View Set

Java 2 Final Inheritance and Classes

View Set

Nutrients and Recommended Intakes

View Set

Management Accounting Multiple Choice

View Set