OSLAB4
OSLAB4
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.
vi. Number of lines that start with one or no c followed by the string ati.