{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Working with the Unix Shell 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 0**. (20 points)\n", "\n", "- Start the [Vim tutorial](http://www.openvim.com)\n", "- Start `emacs` and enter `C-h t` to start the tutorial.\n", "\n", "When you have completed each tutorial, declare \"I have completed the (vi|emacs) tutorial below\" for 10 points each." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 1**. List the folders and files in your home directory, including hidden files. (5 points)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 2.1**. Create the following empty file: `~/turtle/turtle/turrtle/all_the_way_down.txt` (5 points)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 2.2**. Using only Unix shell commands, put the following text into the empty file created in Exercise 2.1 (5 points)\n", "\n", "```\n", "One, two,\n", "Buckle my shoe;\n", "Three, four,\n", "Knock at the door;\n", "Five, six,\n", "Pick up sticks;\n", "Seven, eight,\n", "Lay them straight:\n", "Nine, ten,\n", "A big fat hen;\n", "```\n", "\n", "[Source](https://en.wikipedia.org/wiki/One,_Two,_Buckle_My_Shoe)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 2.3**: Append the following lines to the same file. (5 points)\n", "\n", "```\n", "Eleven, twelve,\n", "Dig and delve;\n", "Thirteen, fourteen,\n", "Maids a-courting;\n", "Fifteen, sixteen,\n", "Maids in the kitchen;\n", "Seventeen, eighteen,\n", "Maids in waiting\n", "Nineteen, twenty,\n", "My plate's empty.\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 2.4**. Print ONLY the date and time the file `~/turtle/turtle/turrtle/all_the_way_down.txt` was last modified. (10 points)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 2.5**. Replace all occurrences of the lower case vowels \"aeiou\" in `~/turtle/turtle/turrtle/all_the_way_down.txt` with the equivalent upper case vowel. (10 points)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 2.6**. Delete the directory `~/turtle` and all its sub-directories and files. (5 points)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "**Exercise 3**. Find all files in the current directory with the word \"buckle\" (case insensitive) and print their names. (5 points)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 4**. Download the following file `https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data` into a file `iris.csv'. Create a new file `iris24.csv` containing just columsn 2 and 4 of `iris.csv`. (10 points)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 5**. Using `emasc` or `vi` (we trust your honesty not to use any other editor), write a bash shell script that finds the average of all numbers in a file that has only 1 column of numbers. Using the script, find the average of the 3rd column of `iris.csv`. (20 points)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Bash", "language": "bash", "name": "bash" }, "language_info": { "codemirror_mode": "shell", "file_extension": ".sh", "mimetype": "text/x-sh", "name": "bash" } }, "nbformat": 4, "nbformat_minor": 2 }