Examine the programs that Coursera offers. Identify several courses or specializations (sequences of courses) that interest you.

  • If you choose individual courses, record the name of each course, its starting date, the university, and the names of the instructors.
  • If you choose specializations, record the name of each specialization, the number of courses in the specialization, the starting date, the name of the university, and the names of the instructors. 

Create a table in the form of a CSV (comma-separated values) file.

  1. Write a Bash script that uses sed (the Unix stream editor) to replace commas in the file with slashes. Here is a tutorial for sed.
  2. Write an AWK program that reads the file and prints the name of a course (or specialization) and university on each row of the output. Here is a tutorial on AWK.

Follow and adapt the example that follows to complete this exercse.

Here are the contents of a very small CSV file that I created. I named the file 'np.csv.'

Acadia National Park, Maine
Theodore Roosevelt National Park, North Dakota

And here is a Bash script that replaces the commas with slashes. I named the file 'np.bash.'

#!/bin/bash

sed 's/,/\//g' $1

Before using this script you must make the file that contains it executable in this way:

chmod ugo+x np.bash

Then you can execute the file like this:

np.bash np.csv

Here is an AWK program that prints the second item in each row first and first item in each row second. I named the file 'np.awk.'

BEGIN {
    FS=",";
}
{
    print $2, $1;
}

Here is how to use the AWK program:

awk -f np.awk np.csv




Last modified: Monday, November 21, 2016, 11:10 AM