Skip to content

Commit 563f835

Browse files
authored
Merge pull request #41 from alexmorley/master
Merge backend update work and docs.
2 parents 5e33c8e + 950eb62 commit 563f835

13 files changed

+9563
-8169
lines changed

Diff for: bundle.js

+426-383
Large diffs are not rendered by default.

Diff for: guide.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<h1>Welcome!</h1>
1515
<p>This is the <strong>command-line bootcamp</strong>, a tutorial that teaches you how to work at the command-line. You'll learn all the basic skills needed to start being productive in the UNIX terminal.</p>
1616
<div style="padding: 0 10px; background: #eeeeee; font-size: 0.8em;">
17-
<p>The bootcamp tutorial text was adapted from <a href="http://rescuedbycode.com/linux-bootcamp">the original</a> by <a href="http://www.keithbradnam.com/">Keith Bradnam</a>. The infrastructure, including <a href="https://github.com/maxogden/adventure-time">adventure-time</a> and <a href="https://github.com/mafintosh/docker-browser-server">docker-browser-server</a>, was built by <a href="https://github.com/maxogden">@maxogden</a> and <a href="https://github.com/maxogden">@mafintosh</a>. The setup of this app was based on the <a href="https://github.com/maxogden/get-dat">get-dat adventure</a>. This adventure was made by <a href="http://rik.smith-unna.com/about">Richard Smith-Unna</a>. This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons 4.0 International License</a>. <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/80x15.png" /></a></p>
17+
<p>The bootcamp tutorial text was adapted from <a href="http://rescuedbycode.com/linux-bootcamp">the original</a> by <a href="http://www.keithbradnam.com/">Keith Bradnam</a>. The infrastructure, including <a href="https://github.com/maxogden/adventure-time">adventure-time</a> and <a href="https://github.com/mafintosh/docker-browser-server">docker-browser-server</a>, was built by <a href="https://github.com/maxogden">@maxogden</a> and <a href="https://github.com/maxogden">@mafintosh</a>. The setup of this app was based on the <a href="https://github.com/maxogden/get-dat">get-dat adventure</a>. This adventure was created by <a href="http://rik.smith-unna.com/about">Richard Smith-Unna</a> and is maintained by <a href="https://alexmorley.me">Alex Morley</a>. This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons 4.0 International License</a>. <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/80x15.png" /></a></p>
1818
<p>Please post feedback at <a href="https://github.com/blahah/command_line_bootcamp/issues">the issue tracker</a></p>
1919
</div>
2020
<h4>Table of Contents</h4>

Diff for: guide/02_the_tree.html

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<section class="content">
1414
<p><a href="index.html">table of contents</a></p>
1515
<h2 id="02-the-unix-tree">02: The Unix tree</h2>
16+
<p><img src="../static/img/Org_Chart_Cacoo_Linux_Tree_John-CC-BY-SA-Tr3quart1sta.png" alt="Unix File Tree"></p>
1617
<p>Looking at directories from within a Unix terminal can often seem confusing. But bear in mind that these directories are exactly the same type of folders that you can see if you use any graphical file browser. From the <em>root</em> level (<code>/</code>) there are usually around 20 directories. You can treat the root directory like any other, e.g. you can list its contents with <code>ls</code>:</p>
1718
<pre><code class="lang-bash">learner@:~$ ls /
1819
bin dev initrd.img lib64 mnt root software tmp vmlinuz

Diff for: guide/13_tab_completion.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<p><a href="index.html">table of contents</a></p>
1515
<h2 id="13-using-tab-completion">13: Using tab completion</h2>
1616
<p>Saving keystrokes may not seem important, but the longer that you spend typing in a terminal window, the happier you will be if you can reduce the time you spend at the keyboard. Especially, as prolonged typing is not good for your body. So the best Unix tip to learn early on is that you can <a href="http://en.wikipedia.org/wiki/Command_line_completion">tab complete</a> the names of files and programs on most Unix systems. Type enough letters that uniquely identify the name of a file, directory or program and press tab...Unix will do the rest. E.g. if you type &#39;tou&#39; and then press tab, Unix should autocomplete the word to &#39;touch&#39; (this is a command which we will learn more about in a minute). In this case, tab completion will occur because there are no other Unix commands that start with &#39;tou&#39;. If pressing tab doesn&#39;t do anything, then you have not have typed enough unique characters. In this case pressing tab <em>twice</em> will show you all possible completions. This trick can save you a LOT of typing!</p>
17-
<p>Navigate to your home directory, and then use the <code>cd</code> command to change to the <code>learning_unix</code> directory. Use tab completion to complete directory name. If there are no other directories starting with &#39;l&#39; in your home directory, then you should only need to type <code>cd</code> + <code>l</code> + <code>tab</code>.</p>
17+
<p>Navigate to your home directory, and then use the <code>cd</code> command to change to the <code>learning_unix</code> directory. Use tab completion to complete directory name. If there are no other directories starting with &#39;l&#39; in your home directory, then you should only need to type <code>cd l</code> and then press your <code>tab</code> key.</p>
1818
<blockquote>
1919
<p><strong><em>Tab completion will make your life easier and make you more productive!</em></strong></p>
2020
</blockquote>

Diff for: guide/25_the_path.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h2 id="26-the-path-environment-variable">26: The $PATH environment variable</h2
1919
learner@:learning_unix$ echo $HOME
2020
/home/learner
2121
learner@:learning_unix$ echo $PATH
22-
/home/learner/.nvm/versions/node/v5.1.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
22+
/home/learner/.nvm/versions/node/v5.1.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2323
</code></pre>
2424
<p>The last one shows the content of the <code>$PATH</code> environment variable, which displays a colon separated list of directories that are expected to contain programs that you can run. This includes all of the Unix commands that you have seen so far. These are files that live in directories which are run like programs (e.g. <code>ls</code> is just a special type of file in the <code>/bin</code> directory).</p>
2525
<p>Knowing how to change your <code>$PATH</code> to include custom directories can be necessary sometimes (e.g. if you install some new software in a non-standard location).</p>

Diff for: guide/26_matching_lines.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ <h2 id="26-matching-lines-in-files-with-grep">26: Matching lines in files with g
8989
</code></pre>
9090

9191
<div class="navlinks">
92-
<a class="nextp button" href="27_combining_commands.html">OK, next! &raquo;</a>
92+
<a class="nextp button" href="27_working_with_columns.html">OK, next! &raquo;</a>
9393
<a class="lastp navlink" href="25_the_path.html">&laquo; back</a>
9494
</div>
9595
</section>

Diff for: guide/27_working_with_columns.html

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>Submarine</title>
5+
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
6+
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700' rel='stylesheet' type='text/css'>
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
8+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/default.min.css">
9+
</head>
10+
<body>
11+
<div class="wrapper">
12+
13+
<section class="content">
14+
<p><a href="index.html">table of contents</a></p>
15+
<h2 id="27-working-with-columns">27: Working with columns</h2>
16+
<p>Along your &quot;command line adventures&quot;, you will encounter many files that are divided in columns, such as &quot;csv&quot; or &quot;tsv&quot; files.</p>
17+
<p>Fortunately, unix has many tools to handle and manipulate this type of files.</p>
18+
<p>First let&#39;s download ourselves a test file and look at it&#39;s contents:</p>
19+
<pre><code class="lang-bash">cd
20+
curl https://raw.githubusercontent.com/Blahah/command_line_bootcamp/master/testfiles/grades.txt &gt; grades.txt
21+
less testfile.vcf
22+
</code></pre>
23+
<p><code>curl</code> will download the contents of any URL you provide it and print it to STDOUT. Since we want our test file on the filesystem, we redirect the output of <code>curl</code> to the file &quot;grades.txt&quot;</p>
24+
<p>As you can see, this file containing hypothetical grades for hypothetical characters. First of all, one character stands out - &quot;Spock&quot;, as he aces every class. Let&#39;s extract his information:</p>
25+
<pre><code class="lang-bash">cut -f 5 grades.txt
26+
</code></pre>
27+
<p>This command provides us with all the rows for column &quot;5&quot; (-f 5), which contains the grades for &quot;Spock&quot; and prints it to STDOUT. Neat, hum?</p>
28+
<p>What else stands out here? &quot;Luke&quot; has a value of 150 where the maximum is 100. He&#39;s probably &quot;forcing&quot; that grade, and that&#39;s cheating. Speaking of cheaters, Malcom is a known cheater, and his scores of 50 on everything raise suspicions. Let&#39;s remove both these students from our file.</p>
29+
<pre><code class="lang-bash">cut -f -2,4-7,9 grades.txt &gt; grades_no_cheaters.txt
30+
</code></pre>
31+
<p>Ok, there is a lot to sink in here. First, the syntax of what the &quot;-f&quot; argument takes: the &quot;-&quot; means &quot;everything up to&quot; when used as the first character, but also means &quot;everything between&quot; when used between two other values (it also can mean &quot;everything after&quot; if used as the last character). Note that we are separating values with &quot;,&quot;. The <code>&gt; grades_no_cheaters.txt</code> will redirect the output into a new file.</p>
32+
<p>Ok, so now let&#39;s add back the cheaters as the last columns of our grades file.</p>
33+
<pre><code class="lang-bash">cut -f 3,8 grades.txt | paste grades_no_cheaters.txt - &gt; sorted_grades.txt
34+
</code></pre>
35+
<p>Easy, wasn&#39;t it? We just cut back the names of the cheaters and then &quot;piped&quot; them to paste which placed the columns in the end of the grades file. The &quot;-&quot; here means &quot;read from STDIN&quot;, and we could use another file instead, to merge the contents of both files.</p>
36+
<p>There you have it. Now all you have to do is read <code>sorted_grades.txt</code> and figure out what to do with the cheating students.</p>
37+
38+
<div class="navlinks">
39+
<a class="nextp button" href="28_combining_commands.html">OK, next! &raquo;</a>
40+
<a class="lastp navlink" href="26_matching_lines.html">&laquo; back</a>
41+
</div>
42+
</section>
43+
</div>
44+
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
45+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
46+
<script>
47+
function neaten(str) {
48+
var pieces = str.split('_');
49+
var s = pieces[1];
50+
s = s.charAt(0).toUpperCase() + s.slice(1);
51+
pieces[1] = s;
52+
return pieces.join(' ');
53+
}
54+
$('.toc-list li a').text(function() {
55+
return neaten($(this).text());
56+
});
57+
</script>
58+
</body>
59+
</html>

Diff for: guide/28_combining_commands.html

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>Submarine</title>
5+
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
6+
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700' rel='stylesheet' type='text/css'>
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
8+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/default.min.css">
9+
</head>
10+
<body>
11+
<div class="wrapper">
12+
13+
<section class="content">
14+
<p><a href="index.html">table of contents</a></p>
15+
<h2 id="28-combining-unix-commands-with-pipes">28: Combining Unix commands with pipes</h2>
16+
<p>One of the most powerful features of Unix is that you can send the output from one command or program to any other command (as long as the second command accepts input of some sort). We do this by using what is known as a <a href="http://en.wikipedia.org/wiki/Pipe_(Unix)">pipe</a>. This is implemented using the &#39;|&#39; character (which is a character which always seems to be on different keys depending on the keyboard that you are using). Think of the pipe as simply connecting two Unix programs. Here&#39;s an example which introduces some new Unix commands:</p>
17+
<pre><code class="lang-bash">learner@:learning_unix$
18+
grep was opening_lines.txt | wc -c
19+
316
20+
21+
learner@:learning_unix$
22+
grep was opening_lines.txt | sort | head -n 3 | wc -c
23+
130
24+
</code></pre>
25+
<p>The first use of <code>grep</code> searches the specified file for lines matching &#39;was&#39;, it sends the lines that match through a pipe to the <code>wc</code> program. We use the <code>-c</code> option to just count characters in the matching lines (316).</p>
26+
<p>The second example first sends the output of <code>grep</code> to the Unix <code>sort</code> command. This sorts a file alphanumerically by default. The sorted output is sent to the <code>head</code> command which by default shows the first 10 lines of a file. We use the <code>-n</code> option of this command to only show 3 lines. These 3 lines are then sent to the <code>wc</code> command as before.</p>
27+
<blockquote>
28+
<p><strong><em>Whenever making a long pipe, test each step as you build it!</em></strong></p>
29+
</blockquote>
30+
31+
<div class="navlinks">
32+
<a class="nextp button" href="29_power_commands.html">OK, next! &raquo;</a>
33+
<a class="lastp navlink" href="27_working_with_columns.html">&laquo; back</a>
34+
</div>
35+
</section>
36+
</div>
37+
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
38+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
39+
<script>
40+
function neaten(str) {
41+
var pieces = str.split('_');
42+
var s = pieces[1];
43+
s = s.charAt(0).toUpperCase() + s.slice(1);
44+
pieces[1] = s;
45+
return pieces.join(' ');
46+
}
47+
$('.toc-list li a').text(function() {
48+
return neaten($(this).text());
49+
});
50+
</script>
51+
</body>
52+
</html>

Diff for: guide/29_power_commands.html

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>Submarine</title>
5+
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
6+
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700' rel='stylesheet' type='text/css'>
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
8+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/default.min.css">
9+
</head>
10+
<body>
11+
<div class="wrapper">
12+
13+
<section class="content">
14+
<p><a href="index.html">table of contents</a></p>
15+
<h2 id="28-miscellaneous-unix-power-commands">28: Miscellaneous Unix power commands</h2>
16+
<p>The following examples introduce some other Unix commands, and show how they could be used to work on a fictional file called <code>file.txt</code>. Remember, you can always learn more about these Unix commands from their respective man pages with the <code>man</code> command. These are not all real world cases, but rather show the diversity of Unix command-line tools:</p>
17+
<ul>
18+
<li>View the penultimate 10 lines of a file (using <a href="http://en.wikipedia.org/wiki/Head_(Unix)">head</a> and <a href="http://en.wikipedia.org/wiki/Tail_(Unix)">tail</a> commands):</li>
19+
</ul>
20+
<pre><code class="lang-bash">tail -n 20 file.txt | head
21+
</code></pre>
22+
<ul>
23+
<li>Show lines of a file that begin with a start codon (ATG) (the <code>^</code> matches patterns at the start of a line):</li>
24+
</ul>
25+
<pre><code class="lang-bash">grep &quot;^ATG&quot; file.txt
26+
</code></pre>
27+
<ul>
28+
<li>Cut out the 3rd column of a tab-delimited text file and sort it to only show unique lines (i.e. remove duplicates):</li>
29+
</ul>
30+
<pre><code class="lang-bash">cut -f 3 file.txt | sort -u
31+
</code></pre>
32+
<ul>
33+
<li>Count how many lines in a file contain the words &#39;cat&#39; or &#39;bat&#39; (<code>-c</code> option of <code>grep</code> counts lines):</li>
34+
</ul>
35+
<pre><code class="lang-bash">grep -c &#39;[bc]at&#39; file.txt
36+
</code></pre>
37+
<ul>
38+
<li>Turn lower-case text into upper-case (using <a href="http://en.wikipedia.org/wiki/Tr_(Unix)">tr</a> command to &#39;transliterate&#39;):</li>
39+
</ul>
40+
<pre><code class="lang-bash">tr &#39;a-z&#39; &#39;A-Z&#39; &lt; file.txt
41+
</code></pre>
42+
<ul>
43+
<li>Change all occurences of &#39;Chr1&#39; to &#39;Chromosome 1&#39; and write changed output to a new file (using <a href="http://en.wikipedia.org/wiki/Sed">sed</a> command):</li>
44+
</ul>
45+
<pre><code class="lang-bash">sed &#39;s/Chr1/Chromosome 1/g&#39; file.txt &gt; file2.txt
46+
</code></pre>
47+
48+
<div class="navlinks">
49+
</div>
50+
</section>
51+
</div>
52+
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
53+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
54+
<script>
55+
function neaten(str) {
56+
var pieces = str.split('_');
57+
var s = pieces[1];
58+
s = s.charAt(0).toUpperCase() + s.slice(1);
59+
pieces[1] = s;
60+
return pieces.join(' ');
61+
}
62+
$('.toc-list li a').text(function() {
63+
return neaten($(this).text());
64+
});
65+
</script>
66+
</body>
67+
</html>

0 commit comments

Comments
 (0)