linux chp5
You are using the grep command, but it is only searching through files in your immediate home directory. What option enables you to search through subdirectories below your home directory?
-r
When you enter the command grep Linux /info/Linux_features | head, what is the maximum number of lines that will be displayed?
10 lines
What addition to the command you used in Exercise 1 can you use to slow the output to one screen at a time?
Add a pipe and use more or less, as in grep host /etc/* | more or grep host /etc/* | less.
List four examples of selection commands.
Any four of the following (from this and previous chapters and from Table 5-1): comm, cut, diff, grep, head, tail, uniq, and wc.
Which of the following is true of the pipe operator? (Choose all that apply.)
It redirects the output of one command to the input of another command.
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.)
Pipe the output into more. and c. Use the -l 23 option..
Briefly explain what you can accomplish with the sed command.
The sed command can be used to edit the contents of one or more files. It enables you to delete lines, substitute text, append text, and show line numbers, for example. You can use one of two forms of sed, One form uses an editing command and the other uses a script file..
Use the grep command to find all the lines that contain the word "celtic" in the CD_list_new file
Type grep "celtic" CD_list_new and press Enter
Use a command to find out which lines in the my_list file contain the word "Foot".
Type grep Foot my_list and press Enter.
Use a command to find the instances in which the word "host" is used in the /etc directory.
Type grep host /etc/* and press Enter.
Determine the number of bytes in both the trees and more_trees files using a one-line command.
Type wc -c trees more_trees and press Enter.
How can you determine the number of lines and words in the /etc/termcap file?
Type wc -lw /etc/termcap and press Enter.
Create a file called trees, containing the following individual lines:Oak tree.Pine tree.Spruce tree.Cottonwood.Maple tree.Use the vi editor to create a file called more_trees and copy in the contents of the trees file (if the first line is blank, delete it). Next, add the following trees at the end of the list. Redwood.Willow tree.Use a command to compare the trees and more_trees files and that outputs the differences in columns.
Use the vi editor to create the trees file. Use the vi editor with the :r option to import the trees file into the more_trees file and then add the new lines. Type comm trees more_trees and press Enter.
When you use the Awk printf capability, what does the dollar sign ($) represent?
a data field
What is the general format for using the pipe operator?
first_command | second command or first_command | second command | third_command (more commands can be piped)
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 reference "data is" to "data are" before you submit it. Which of the following commands can you use to locate these references in the file for a quick assessment of how much you have to change?
grep "data is" /assignments/data_sources
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?
ls -l | more
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?
sh
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?
wc -c
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?
wc -w /assignments/data_sources