|
11 | 11 | "# Linux/Unix Command and Bash Scripting (Markdown Code Blocks)"
|
12 | 12 | ]
|
13 | 13 | },
|
| 14 | + { |
| 15 | + "cell_type": "markdown", |
| 16 | + "metadata": {}, |
| 17 | + "source": [ |
| 18 | + "## Getting Started\n", |
| 19 | + "\n", |
| 20 | + "This lecture can be found on `state`.\n", |
| 21 | + "\n", |
| 22 | + "Let's all SSH into `state`.\n", |
| 23 | + "\n", |
| 24 | + "```sh\n", |
| 25 | + "ssh leunge@state.ohsu.edu\n", |
| 26 | + "```\n", |
| 27 | + "\n", |
| 28 | + "And navigate to your folder.\n", |
| 29 | + "\n", |
| 30 | + "```sh\n", |
| 31 | + "cd /home/courses/BMI565/students\n", |
| 32 | + "```" |
| 33 | + ] |
| 34 | + }, |
14 | 35 | {
|
15 | 36 | "cell_type": "markdown",
|
16 | 37 | "metadata": {
|
|
67 | 88 | },
|
68 | 89 | {
|
69 | 90 | "cell_type": "markdown",
|
70 | | - "metadata": { |
71 | | - "heading_collapsed": true |
72 | | - }, |
| 91 | + "metadata": {}, |
73 | 92 | "source": [
|
74 | 93 | "#### `pwd`"
|
75 | 94 | ]
|
76 | 95 | },
|
77 | 96 | {
|
78 | 97 | "cell_type": "markdown",
|
79 | | - "metadata": { |
80 | | - "hidden": true |
81 | | - }, |
| 98 | + "metadata": {}, |
82 | 99 | "source": [
|
83 | 100 | "You can use `pwd` to show you where you are in your computer."
|
84 | 101 | ]
|
85 | 102 | },
|
86 | 103 | {
|
87 | 104 | "cell_type": "code",
|
88 | 105 | "execution_count": null,
|
89 | | - "metadata": { |
90 | | - "hidden": true |
91 | | - }, |
| 106 | + "metadata": {}, |
92 | 107 | "outputs": [],
|
93 | 108 | "source": [
|
94 | 109 | "pwd"
|
95 | 110 | ]
|
96 | 111 | },
|
97 | 112 | {
|
98 | 113 | "cell_type": "markdown",
|
99 | | - "metadata": { |
100 | | - "heading_collapsed": true |
101 | | - }, |
| 114 | + "metadata": {}, |
102 | 115 | "source": [
|
103 | 116 | "#### `ls`"
|
104 | 117 | ]
|
105 | 118 | },
|
106 | 119 | {
|
107 | 120 | "cell_type": "markdown",
|
108 | | - "metadata": { |
109 | | - "hidden": true |
110 | | - }, |
| 121 | + "metadata": {}, |
111 | 122 | "source": [
|
112 | 123 | "After knowing where you are, you should find out what files and directories are around you.\n",
|
113 | 124 | "\n",
|
|
126 | 137 | "cell_type": "code",
|
127 | 138 | "execution_count": null,
|
128 | 139 | "metadata": {
|
129 | | - "hidden": true, |
130 | 140 | "scrolled": false
|
131 | 141 | },
|
132 | 142 | "outputs": [],
|
|
937 | 947 | "- [Bash One-Liners Explained, Part III: All about redirections](http://www.catonmat.net/blog/bash-one-liners-explained-part-three/)"
|
938 | 948 | ]
|
939 | 949 | },
|
| 950 | + { |
| 951 | + "cell_type": "markdown", |
| 952 | + "metadata": {}, |
| 953 | + "source": [ |
| 954 | + "## Exercise Break! (See below)" |
| 955 | + ] |
| 956 | + }, |
940 | 957 | {
|
941 | 958 | "cell_type": "markdown",
|
942 | 959 | "metadata": {},
|
|
1070 | 1087 | },
|
1071 | 1088 | {
|
1072 | 1089 | "cell_type": "markdown",
|
1073 | | - "metadata": { |
1074 | | - "heading_collapsed": true |
1075 | | - }, |
| 1090 | + "metadata": {}, |
1076 | 1091 | "source": [
|
1077 | 1092 | "#### Resources and More\n",
|
1078 | 1093 | "\n",
|
|
1112 | 1127 | },
|
1113 | 1128 | {
|
1114 | 1129 | "cell_type": "markdown",
|
1115 | | - "metadata": { |
1116 | | - "heading_collapsed": true |
1117 | | - }, |
| 1130 | + "metadata": {}, |
1118 | 1131 | "source": [
|
1119 | 1132 | "#### Resources and More\n",
|
1120 | 1133 | "\n",
|
|
1587 | 1600 | "source": [
|
1588 | 1601 | "```sh\n",
|
1589 | 1602 | "# Create bash script\n",
|
1590 | | - "echo \"#!/usr/bin/env bash\n", |
| 1603 | + "echo '#!/usr/bin/env bash\n", |
1591 | 1604 | "\n",
|
1592 | 1605 | "head -n 1 ../README.md\n",
|
1593 | 1606 | "\n",
|
1594 | 1607 | "if [[ $? -eq 0 ]]; then\n",
|
1595 | | - " echo 'Successfully read beginning of file'; exit 0\n", |
| 1608 | + " echo \"Successfully read beginning of file\"; exit 0\n", |
1596 | 1609 | "else\n",
|
1597 | | - " echo 'Failed to read beginning of file'; exit 1\n", |
1598 | | - "fi\" > test_exit_codes.sh\n", |
| 1610 | + " echo \"Failed to read beginning of file\"; exit 1\n", |
| 1611 | + "fi' > test_exit_codes.sh\n", |
1599 | 1612 | "\n",
|
1600 | 1613 | "# Run bash script from above\n",
|
1601 | 1614 | "bash test_exit_codes.sh\n",
|
|
1826 | 1839 | "- [Unix / Linux: sftp File From One Server To Another](https://www.cyberciti.biz/faq/sftp-file-from-server-to-another-in-unix-linux/)"
|
1827 | 1840 | ]
|
1828 | 1841 | },
|
| 1842 | + { |
| 1843 | + "cell_type": "markdown", |
| 1844 | + "metadata": {}, |
| 1845 | + "source": [ |
| 1846 | + "## Exercise Break! (See below)" |
| 1847 | + ] |
| 1848 | + }, |
1829 | 1849 | {
|
1830 | 1850 | "cell_type": "markdown",
|
1831 | 1851 | "metadata": {},
|
|
2047 | 2067 | "all : file1_count.txt file2_count.txt file3_count.txt\n",
|
2048 | 2068 | "\n",
|
2049 | 2069 | "create :\n",
|
2050 | | - " echo -e \"1\\n2\\n3\\n4\\n5\\n6\" > file1.txt\n", |
2051 | | - " echo -e \"Hello, world!\" > file2.txt\n", |
2052 | | - " echo -e \"We're learning bash programming!\" > file3.txt\n", |
| 2070 | + " echo -e '1\\n2\\n3\\n4\\n5\\n6' > file1.txt\n", |
| 2071 | + " echo -e 'Hello, world!' > file2.txt\n", |
| 2072 | + " echo -e 'We're learning bash programming!' > file3.txt\n", |
2053 | 2073 | "\n",
|
2054 | 2074 | "%_count.txt : %.txt\n",
|
2055 | 2075 | " wc $< > $@\n",
|
|
2147 | 2167 | "## Exercises"
|
2148 | 2168 | ]
|
2149 | 2169 | },
|
| 2170 | + { |
| 2171 | + "cell_type": "code", |
| 2172 | + "execution_count": null, |
| 2173 | + "metadata": {}, |
| 2174 | + "outputs": [], |
| 2175 | + "source": [] |
| 2176 | + }, |
2150 | 2177 | {
|
2151 | 2178 | "cell_type": "markdown",
|
2152 | 2179 | "metadata": {},
|
|
2165 | 2192 | "\n",
|
2166 | 2193 | "### Exercise 2 Download Data and Chop It Up\n",
|
2167 | 2194 | "\n",
|
2168 | | - "Create a bash script to download the processed Long Beach V.A. data `processed.va.data` from the [Heart Disease Data Set](https://archive.ics.uci.edu/ml/datasets/Heart+Disease)and filter out for just subjects with Class 0 (last column). Save this subset of the data to a separate file.\n", |
| 2195 | + "Create a bash script to download the processed Long Beach V.A. data `processed.va.data` from the [Heart Disease Data Set](https://archive.ics.uci.edu/ml/datasets/Heart+Disease)and filter out for just subjects with Class 0 (last column). Save this subset of the data to a separate file.\n", |
2169 | 2196 | "\n",
|
2170 | 2197 | "The data can be found [here](https://archive.ics.uci.edu/ml/machine-learning-databases/heart-disease/).\n",
|
2171 | 2198 | "\n",
|
| 2199 | + "**Hint**: Use `wget`/`curl` to download file and `awk` to subset data.\n", |
| 2200 | + "\n", |
2172 | 2201 | "### Exercise 3 Search for Codons\n",
|
2173 | 2202 | "\n",
|
2174 | 2203 | "Using the random DNA sequence Python script from Exercise 1, generate a random sequence of DNA and count the number of times the DNA sequence \"TAA\" (a stop codon).\n",
|
2175 | 2204 | "\n",
|
| 2205 | + "**Hint**: Use `grep` to count number of occurrences. You can use the `-c` flag for `grep` to count things.\n", |
| 2206 | + "\n", |
2176 | 2207 | "**Bonus**: Simultaneously find all three stop codons: \"TAA\", \"TAG\", \"TGA\" and count them each."
|
2177 | 2208 | ]
|
2178 | 2209 | },
|
|
0 commit comments