{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Session contents" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Text processing with `sed`\n", "\n", "- Use of `!` for negation\n", "- Use of `-n`, `-i` and `-f` flags\n", "- Use of `g`, `p`, and `w` commands" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Construction of shell script\n", "\n", "- Review of steps" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Variables\n", "\n", "- Variables `${var}`\n", "- Length of variable `${#var}`\n", "- Removing substrings `${var#}`, `${var##}`, `${var%}`, `${var%%}`\n", "- Pattern substitution `${var/p/r}`, `${var//p/r}`\n", "- Prefix and suffix substitution `${var/#p/r}`, `${var/%p/r}`\n", "- Use of `declare` with `-i`, `-r` attributes" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Arrays\n", "\n", "- Index and associative arrasys with `decalre -a`, `declare -A`\n", "- Indexing with `$arr`, `${arr[0]}`, `$arr[@]`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Conditionals" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- tests with `[[]]` and `(())`\n", "- test file operators" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Branching" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- `if`\n", "\n", "```bash\n", "if CONDITION then;\n", " commands\n", "fi\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- `case`\n", "\n", "```bash\n", "case EXPR in\n", "PATTERN)\n", " commands ;;\n", "Pattern\n", " commands ;;\n", "esac\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Looping" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- `for` type 1\n", "\n", "```bash\n", "for EXPR in Sequence\n", "do\n", " commands\n", "done\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- `for` type 2\n", "\n", "```bash\n", "for (( i=0; i