Solution to exercises on fundamental technologies

Exercise 1: Make a README-file

  1. Done with:
cd in5800-intro
  1. The file README.md should contain:
# Readme

This repo is used for the intro exercises in IN5800.
  1. Done with the follwoing three commands:
git add README.md
git commit -m "Add README-file."
git push origin master

Exercise 2: Download and manage files

  1. Done with the two commands:
mkdir downloads
mkdir data
  1. Done with the following command (note -O downloads/data.zip stores the downloaded file at downloads/data.zip):
wget -O downloads/data.zip https://leifhka.org/in5800/lectures/intro/data.zip
  1. Done by using unzip as follows (note -d data/ extracts the files into the data-folder):
unzip -d data/ downloads/data.zip
  1. Done with the more complicated command:
cat data/data.csv | grep -e "^IN5800"
  1. Done by using rm with the -r flag to also remove contained files:
rm -r downloads
rm -r data

Exercise 3: Make Makefile

  1. The Makefile should look like this:
folders:
    mkdir downloads
    mkdir data

downloads/data.zip: folders
    wget -O downloads/data.zip https://leifhka.org/in5800/lectures/intro/data.zip

data/data.csv: downloads/data.zip
    unzip -d data/ downloads/data.zip

in5800_data: data/data.csv
    cat data/data.csv | grep -e "^IN5800"

clean:
    rm -r downloads
    rm -r data
  1. make in5800_info
  2. make clean
  3. The README.md-file should now look like this:
# Readme

This repo is used for the intro exercises in IN5800.

# Use

Below is a list of useful **commands**:

- `in5800_info`
- `clean`
  1. Done with:
git add README.md Makefile
git commit -m "Add a Makefile to automate the information extraction."
git push origin master

Exercise 4: Branching and Make-variables

  1. Branches are made with the git checkout command with the -b-flag as follows (which automatically switches you to it):
git checkout -b feature/URLs-in-vars
  1. The Makefile should now look like this (note the need for $ and parenthesis when variables are used in Makefiles):
data_url = https://leifhka.org/in5800/lectures/intro/data.zip

folders:
    mkdir downloads
    mkdir data

downloads/data.zip: folders
    wget -O downloads/data.zip $(data_url)

data/data.csv: downloads/data.zip
    unzip -d data/ downloads/data.zip

in5800_data: data/data.csv
    cat data/data.csv | grep -e "^IN5800"

clean:
    rm -r downloads
    rm -r data
  1. Simply make in5800_data and make clean as before
  2. Again:
git add Makefile
git commit -m "Move URL into variable."
git push origin feature/URLs-in-vars
  1. Done with (note that merge only merges the branches locally, so a push is necessary to update the remote repo):
git checkout master
git merge feature/URLs-in-vars
git push origin master