0% found this document useful (0 votes)
5 views

Lab Assignment 3

This document is a lab assignment for first-year students at the Higher School of Computer Science, focusing on redirection and piping in operating systems. It includes a series of tasks that require students to use command-line utilities to manipulate file outputs, handle standard input and output, and understand command chaining and piping. The assignment is divided into two modules, with specific commands and explanations required for each task.

Uploaded by

hadjerhiba60
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lab Assignment 3

This document is a lab assignment for first-year students at the Higher School of Computer Science, focusing on redirection and piping in operating systems. It includes a series of tasks that require students to use command-line utilities to manipulate file outputs, handle standard input and output, and understand command chaining and piping. The assignment is divided into two modules, with specific commands and explanations required for each task.

Uploaded by

hadjerhiba60
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1st year of the first cycle Higher School of Computer Science

Course : Introduction to operating system 1 Sidi Bel Abbes (ESI-SBA)

Lab assignment N°3


Redirection and Piping
Module 1 :

1. Use the script utility to capture your session.


2. Redirect the output of the home directory into a text file (files.txt).
3. Write down the command to do a detailed directory listing and send the standard output
(stdout) to the same file (overwriting the file, i.e., clobbering).
4. Redirect the content of the /etc/passwd into a file (users.txt).
5. Write down the command to display the detailed information of /etc/passwd by avoiding
clobbering a file (i.e., append to a file).
6. Run the following command and observe the output :
find /etc -name hosts
7. Write down the command, so that you avoid displaying error messages (redirect them to a
special file /dev/null).
8. Send the error messages (stderr) into a file (err.txt).
9. Send the normal output (stdout) into a file (out.txt).
10. Redirect both standard output (stdout) and standard error (stderr) to one file (outputs.txt).
11. Test the command sort by default, what does it perform ? use the standard input (stdin) that
comes from the keyboard, and displays the processed data to the standard output (screen).
(Note : Press control-d, to signal the sort command to stop processing standard input).
12. Execute the sort command by redirecting stdin from a file (input.txt).
13. Write down the command, so that you redirect the stdout to a file (sorted.txt).
14. Exit out the script. Save the output file so you can continue with Module 2.

Module 2 :

1. Start script again and append to the existing output file of step 14
2. Explain the task of the following commands-chaining :
sort < files.txt > temp ; head -5 < temp ; rm temp
(Note that files.txt contains a detailed listing of your home directory; (ls -l ~ > files.txt))
3. Write down the command, so that you transform it to a piping that performs the same task.
4. Write down the piping, so that you replace files.txt with ls -l ~ (i.e., original command that we
redirected its output to files.txt). Is it workable ? Justify ?
5. Re-write the command, so that you can perform a correct piping and append the output to
files.txt.
6. Exit out of script.

You might also like