Problem

In this hands-on project, you redirect stdout and stdin using pipe shell metacharacters....

In this hands-on project, you redirect stdout and stdin using pipe shell metacharacters.

1. Switch to a command-line terminal (tty2) by pressing Ctrl+Alt+F2 and log in to the terminal using the user name of root and the password of secret.

2. At the command prompt, type cat /etc/httpd/conf/httpd.conf and press Enter to view the /etc/httpd/conf/httpd.conf file. Next, type cat/etc/httpd/conf/ httpd.conf | less at the command prompt and press Enter to perform the same task page-by-page. Explain what the | shell metacharacter does in the previous command. How is this different from the less/etc/httpd/conf/httpd.conf command?

3. At the command prompt, type cat /etc/httpd/conf/httpd.conf | grep Keep and press Enter. How many lines are displayed? Why did you not need to specify a filename with the grep command?

4. At the command prompt, type cat /etc/httpd/conf/httpd.conf | grep Keep | tr e E and press Enter. Explain the output on the terminal screen.

5. At the command prompt, type cat /etc/httpd/conf/httpd.conf | grep Keep | tr e E | sort –r and press Enter. Explain the output on the terminal screen.

6. At the command prompt, type cat /etc/httpd/conf/httpd.conf | grep Keep | tr e E | sort –r | tee file and press Enter. Explain the output on the terminal screen. Next, type cat file at the command prompt and press Enter. What are the contents? Why? What does the tee command do in the pipe above?

7. At the command prompt, type cat /etc/httpd/conf/httpd.conf | grep Keep | tr e E | sort –r | tee file | wc –l and press Enter. Explain the output on the terminal screen. Next, type cat file at the command prompt and press Enter. What are the contents and why?

8. At the command prompt, type cat /etc/httpd/conf/httpd.conf | grep Keep | sed /#/d | sed /Max/s/100/150/ and press Enter. Explain the output on the terminal screen. Can this output be obtained with the grep and tr commands instead of sed? Which is easier?

9. At the command prompt, type cat /etc/hosts. Next, type cat /etc/hosts | awk ’/localhost/ {print $1, $3}’ and press Enter. Explain the output on the terminal screen.

10. Type exit and press Enter to log out of your shell.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 7