Ch. 7 – Working with Bash
Enter your answers into this document in bold, and then upload it to the instructor via Moodle.
PART ONE: Textbook
Answer each question posed in these projects and insert the answers in order in Bold into this document directly under the project description. No need to enter the questions, only the answers. If asked to login to user1, use your personal account instead. When asked for passwords, use the ones you created on your system.
1. Do Project 7-1, pp. 335-336. In step 3, be sure you don’t have a sample3 file in the directory before entering the ls command. In step 13, use this command ls -l sample1 sample2 sample3 2>file2 >&2 instead of the one shown.
2. Do Project 7-2, pp. 336-337. In step 8, you use the stream editor sed, see pp. 304-305. In step 9, you use the pattern scanning and processing language awk, see pg. 306.
3. Do Project 7-3, pp. 337-338.
4. Do Project 7-4, pg. 339.
5. Do Discovery Exercise 5, pg. 344, as follows: Rather than describe what each line in the file does, enter the appropriate line(s) from .bash_profile on your system (which will be different than the file shown on pg. 344) immediately below the descriptions here:
Comments.
Set environment variable(s).
Exports these variables so they can be used in subshells.
The if statement that says if the hidden file .bashrc exists in the user’s home directory, then execute it.
6. Do Discovery Exercise 6, pg. 344. Include the shell script immediately below.
7. Additional Project. Indicate the command that can be used to:
a. Create an alias call mm that displays only those devices that are mounted and contain an ext4 filesystem.
b. Create a variable called NEWHOME that is equivalent to the value contained in the HOME variable.
c. Starting from the /etc directory find all the files whose names begin with the word “hosts” and save the stdout to a file named file1.
d. Display only the lines from the output of the set command that have the word “bash” regardless of case in them. The output on the terminal screen should be sorted alphabetically.
Upload this document including your answers in Bold through Moodle.