Skip to content

Commit

Permalink
Finishing pass
Browse files Browse the repository at this point in the history
[skip travis]
  • Loading branch information
matsen committed Oct 23, 2019
1 parent 271a382 commit 6af1f8d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
16 changes: 13 additions & 3 deletions lectures/lecture09/directories/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Directories

Execute

cd directories

Congratulations, you just changed directory using `cd`, which is short for "change directory".
By executing `cd directories` you moved your current location inside a directory called `directories`.
You can think about this being like double clicking on a folder in a graphical user interface.
Expand Down Expand Up @@ -32,7 +36,13 @@ Now give that command a part of your path, so see the list of files at various p
### Tree

Of course, directories can be nested and so it's not always easy to get an overall view of what is where.
For this there is the `tree` command, which will show a nested directory structure as a tree:
For this there is the `tree` command, which will show a nested directory structure as a tree.

Try

tree

The output should look like

.
├── purchase
Expand All @@ -58,10 +68,10 @@ The `tree` command can also take an argument, which is the directory for which i
Experienced shell users do not write out the full names of files or directories.
Instead, they use the tab key to have the shell complete file names for them.

For example, try typing `ls seq` and then hitting the tab key.
For example, try typing `ls REA` and then hitting the tab key.

This also works to make your way through directories!
Try `ls dir`, and tab.
Try `ls pur`, and tab.
Now just hit tab a few more times.
The shell should bring up some options, and you can select between them by typing the first letter or so and hitting tab again.
Continue doing this until you run out of directories.
Expand Down
12 changes: 6 additions & 6 deletions lectures/lecture09/first-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ What happens?

More generally, shell commands look like

command flags arguments
`command` `flags` `arguments`

where `flags` and `arguments` are optional.
We separate these components with spaces (extra spaces are fine).
Expand Down Expand Up @@ -64,10 +64,10 @@ Flags modify some form of the command behavior, and can range from simple to rat

Flags can have arguments, like

ls -w 15 /
ls -w 50 /

in which we give the `-w` flag the value of 15.
The `-w` flag tells `ls` that the user wants to wrap output to some number of letters wide and no wider, in this case 15 letters wide.
in which we give the `-w` flag the value of 50.
The `-w` flag tells `ls` that the user wants to wrap output to some number of letters wide and no wider, in this case 50 letters wide.

Try varying the argument to `-w` from very small to very large.
Are negative numbers allowed?
Expand Down Expand Up @@ -133,7 +133,7 @@ to learn about the command `man`.
2. save this information somewhere (on a piece of paper?)


## A quick practicum
## On your own

Use any method you like to find documentation about the `wc` command, then use it to count the number of lines in `sequence.gb`.

Expand All @@ -143,4 +143,4 @@ Use any method you like to find documentation about the `wc` command, then use i
Congratulations!
You now know how to navigate around the file system.

For the next step, execute `cd directories` then `less README.md` to work through the next part of the adventure
For the next step, look at the README file in the `directories` directory to work through the next part of the adventure.
17 changes: 9 additions & 8 deletions lectures/lecture09/scripting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ You can make your shell script like executing a normal command by

Now you should be able to run your script with `./script1.sh`.

Next we'll be playing around scripting with samtools.
Please download [this bam file](https://console.cloud.google.com/storage/browser/_details/gatk-test-data/wgs_bam/NA12878_20k_b37/NA12878.bam) and move it to the same directory as where your scripts live.
Next we'll be playing around scripting with samtools using [this bam file](https://console.cloud.google.com/storage/browser/_details/gatk-test-data/wgs_bam/NA12878_20k_b37/NA12878.bam) that's available to you in the GitHub repository.

It has an awkward name, so let's rename it `input.bam`.
In the shell you would do that with
It has an awkward name, so let's rename it `input.bam` with

mv wgs_bam_NA12878_20k_b37_NA12878.bam input.bam

Expand All @@ -72,7 +70,8 @@ You first need to prepare this file like so:

samtools index input.bam

Samtools has a nice command line user interface that has commands within the command. The format is like
Samtools has a nice command line user interface that has commands within the command.
The format is like

samtools COMMAND ETC

Expand All @@ -89,7 +88,9 @@ Rather than using `head`, try piping to something that will allow you to scroll.

## ERRORS!!!

Try running `./script2.sh`.
Try running `./script2.sh` via

./script2.sh

* What happened?
* Did the script run to completion?
Expand All @@ -112,9 +113,9 @@ Now we will learn something very important...

## Don't write shell

"Classic" shell is a rich programming language.
"Classic" shell is a complex programming language.
The most frequently used shell, called "bash", [is way more complex](https://www.tldp.org/LDP/abs/html/).
However, I do not suggest that you use shell in this way.
However, I do not suggest that you write complex shell scripts.

Rather, I suggest that once you start to need more than just executing a series of commands, you reach for a general-purpose programming language such as Python.
Speaking from personal experience and experience of those in my group, scripts often get increasingly complex to the point where one is doing more complex manipulations that are more suited to a more complete programming language.
Expand Down
3 changes: 1 addition & 2 deletions lectures/lecture09/vim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Vi is a wonderful, powerful, but arcane editor.
It's worth being able to use because even the sparsest linux install will have some variant of vi.
Also, when working with remote machines, it's nice to be able to edit text in a powerful editor directly on that machine.
Finally, sometimes another program (e.g. git) will plop you into vim without you realizing it, so it's nice to know what to do in this situation.
In addition, many programs, such as `less` use vim keybindings for fast navigation.
In addition, many programs, such as `less` and Jupyter notebook use vim keybindings for fast navigation.


## The simplest `vi` session
Expand Down Expand Up @@ -109,7 +109,6 @@ Here we'll be a little specific and say that the software we've been calling `vi

* a [cheat-sheet](http://i.imgur.com/YLInLlY.png)
* a [wallpaper](https://github.com/LevelbossMike/vim_shortcut_wallpaper)

* [Ben Crowder's vim tips](http://bencrowder.net/files/vim-fu/)
* The `vimtutor` command, available wherever you find `vim`
* [An online vim tutorial](http://www.openvim.com/)
Expand Down

0 comments on commit 6af1f8d

Please sign in to comment.