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

OSLAB4

The document outlines a series of practical exercises for an Operating System lab, focusing on file management and command-line operations. Tasks include listing directory contents, sorting files, displaying specific lines from system files, counting words and characters, and using grep for pattern matching. The exercises emphasize the use of input and output redirection in a Unix-like environment.

Uploaded by

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

OSLAB4

The document outlines a series of practical exercises for an Operating System lab, focusing on file management and command-line operations. Tasks include listing directory contents, sorting files, displaying specific lines from system files, counting words and characters, and using grep for pattern matching. The exercises emphasize the use of input and output redirection in a Unix-like environment.

Uploaded by

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

Operating System Lab 4 Phy Vathanak

Practical Exercises:
1. List the contents of your current directory, including the ownership and permissions,
and redirect the output to a file called contents.txt.

2. Sort the contents of the contents.txt file from your current directory and append it to
the end of a new file named contents-sorted.txt
3. Display the last 10 lines of the /etc/passwd file and redirect it to a new file in your
user’s Documents directory.

4. Count the number of words within the contents.txt file and append the output to the
end of a file field2.txt in your home directory. You will need to use both input and
output redirection.
5. Display the first 5 lines of the /etc/passwd file and sort the output reverse
alphabetically.
6. Using the previously created contents.txt file, count the number of characters of the
last 9 lines.

7. Count the number of files called test within the /usr/share directory and its
subdirectories. Note: each line output from the find command represents a file.
8. Using grep and the /usr/share/hunspell/en_US.dic file, find the lines that match the
following criteria:
i. All lines containing the word cat anywhere on the line.
It contain more word but I just screen short a bit of them

ii. All lines that do not contain any of the following characters: sawgtfixk.

iii. All lines that start with any 3 letters and the word dig.

iv. All lines that end with at least one e.


v. All lines that contain one of the following words: org , kay or tuna.

vi. Number of lines that start with one or no c followed by the string ati.

You might also like