Solution to exercises on fundamental technologies
Exercise 1: Make a
README-file
- Done with:
cd in5800-intro
- The file
README.md should contain:
# Readme
This repo is used for the intro exercises in IN5800.
- 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
- Done with the two commands:
mkdir downloads
mkdir data
- 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
- Done by using
unzip as follows (note
-d data/ extracts the files into the
data-folder):
unzip -d data/ downloads/data.zip
- Done with the more complicated command:
cat data/data.csv | grep -e "^IN5800"
- Done by using
rm with the -r flag to also
remove contained files:
rm -r downloads
rm -r data
Exercise 3: Make Makefile
- 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
make in5800_info
make clean
- 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`
- 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
- 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
- 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
- Simply
make in5800_data and make clean as
before
- Again:
git add Makefile
git commit -m "Move URL into variable."
git push origin feature/URLs-in-vars
- 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