Thinking in C and *nix (CSC 282 2015S) : EBoards

CSC282 2015S, Class 02: Some Basic Tasks and Corresponding Tools


Overview

Preliminaries

Admin

Questions

Are your questions intended to be as open-ended as they seem?

Yes. I look forward to discussing interesting answers. We won't discuss all of them, though.

Fun with GitHub

Problems

Go over homework

Given a DOS-formatted text file (lines end with \r\n rather than just \n), convert it to a standard text file.

Strategy two: Use tr (translate). Traditionally used to translate one character to another. Can also delete characters if you use the -d flag.

    tr -d '\r' < original.dos > fixed.txt

Strategy 3: Use dos2unix, which is not a standard program. Five minutes.

Strategy 4: Find a more sophisticated text translation tool and translate "\r\n" to "\n". The sed program is great for this

    sed -e 's/\r\n/\n/g' < original.dos > fixed.txt

Given a standard text file, convert all uppercase letters to lowercase.

Given a standard text file, remove all blank spaces at the end of lines.

Make a list of all misspelled words in a text file.

    aspell list < file
    aspell list < file | uniq
    aspell list < file | sort | uniq
    spell file | sort -u

Given a CSV file in which each line has the form LastName,FirstName,Assignment,NumericGrade find the the five highest grades on homework 2.

    Hint: cut, sort, head

Given an HTML file, find the URLs of all images. In case you don't know HTML, those will typically look like <img ... src="*URL*" ...> The img can have any capitalization (img, IMG, Img, iMg, etc.) There can be other text between the img and the src. (That text cannot include a greater than sign.)

Raymond, chapter 1

Thinking about basic tools

Homework

  1. Learn Markdown so that we can use it for these assignments.

  2. Learn about how you set and get environment variables. Put your explanations in your personal directory for the assignment.

    • Command line
    • Bash
    • C (get only)
  3. Come up with two or three tasks, similar to those we did for assignment 1, and put notes about them in the tasks directory. (You can include some sample solutions in your file.)

  4. Read the first chapter of the Make book.

Sam's Fun Programming Problem