Skip to main content

L01 - Command Line Fundamentals

Introduction

This lab will require you to use the knowledge you gained from Module 01 of UNIX, the command line, and Git.

Prerequisites

By now, you should have your development environment set up and ready to go. After accepting the assignment in GitHub Classroom, you should have a repository created for you to work in. You will need to clone the lab repository by running the following command in your development environment:

git clone <your-repository-url> lab-01

After cloning the repository, you should have a new directory called lab-01 in your development environment. You will be working in this directory for the duration of the lab.

Some Useful Commands

Here are some useful commands that you may want to use during the lab:

  • man <command> - displays the manual page for a command
  • grep - searches for a pattern in a file
  • cat - displays the contents of one or more files
  • head - displays the first few lines of a file
  • tail - displays the last few lines of a file
  • comm - compares two sorted files line by line
  • sort - sorts the contents of a file (alphabetically by default)
  • uniq - removes duplicate consecutive lines from a file
  • aspell - spell checker

Data Files

In this lab, you will be working with the following data files fond in /data/:

  • some_words.txt - a text file containing a list of words
  • some_more_words.txt - a text file containing a list of words
  • essay.txt - a text file containing an essay
  • server.log - a log file from a server

Tasks

Pipe your results for each task into its corresponding file in the results/ directory.

  1. server_errors.txt - List all the error messages in server.log.

  2. all_words.txt - List all unique words used in some_words.txt and some_more_words.txt in alphabetical order.

    Hint

    You can cat multiple files.

  3. common_words.txt - List all the words that are common between some_words.txt and some_more_words.txt.

    Hint

    You may want to use the comm command to compare the two files. Check its manual page to see how to use it.

  4. misspelled.txt - List all the unique misspelled words in essay.txt according to aspell in alphabetical order.

    Hint

    It may be helpful to look at aspell's manual page to see how to use it. You can do this by running man aspell. You can also use the --help flag to see a list of options.

    You probably want to somehow list any misspelled words. 😉

Submission

After completing the tasks, you should have four files in the results/ directory. You should commit and push these files to your repository by running the following commands:

git add results/
git commit -m "<your-message>"
git push

After pushing your changes, you should see the files in your repository on GitHub. You can verify this by visiting your repository on GitHub and navigating to the results/ directory.

Now, submit your repository to the Gradescope assignment for this lab. You will be able to see the results of the testcases run on your repository. You can resubmit as many times as you like before the deadline.