From: Paul P.H. Wilson Date: Fri, 26 Apr 2013 16:29:14 +0000 (-0500) Subject: Some formatting and flow changes: X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c2f9ab854e41bbc061eb0af4509515ec1c7666dd;p=swc-modular-shell-hearing.git Some formatting and flow changes: * try to bring formatting of subheadings into consistency by promoting all bolded headings to hierarchichal headings * add Paul Wilson as author * initial directory changing and git checkout flow was not consistent with following commands * added excercise around man pages and ls * added comment on mental model of directory hierarchy * labeled exercise at end of path section * clarified conditions under which different ls commands were equivalent --- diff --git a/shell/Readme.md b/shell/Readme.md index 2c29e25..df0685e 100644 --- a/shell/Readme.md +++ b/shell/Readme.md @@ -1,6 +1,6 @@ # The Shell -**Material by Milad Fatenejad, Sasha Wood, and Radhika Khetani** +**Material by Paul Wilson, Milad Fatenejad, Sasha Wood, and Radhika Khetani** # What is the shell how do I access the shell? @@ -52,13 +52,9 @@ command: git clone -b YYYY-MM-PLACE https://github.com/USERNAME/boot-camps.git -Followed by: - - cd boot-camps - git checkout YYYY-MM-PLACE - -These 2 commands will grab all of the data needed for this workshop from the -internet. +This command will grab all of the data needed for this workshop from +the internet. (We will talk about the `git` command later in the +workshop.) # Let's get started @@ -94,7 +90,7 @@ directory. This is the home directory for the `swc` user. That is our user name. You can always find out your user name by entering the command `whoami`. -**File Types** +## File Types When you enter the `ls` command lists the contents of the current directory. There are several items in the home directory, notice that @@ -134,7 +130,7 @@ The `rm` command can be used to remove files. If you enter `ls` again, you will see that `testfile` is gone. -**Changing Directories** +## Changing Directories Now, let's move to a different directory. The command `cd` (change directory) is used to move around. Let's move into the `boot-camps` @@ -178,7 +174,20 @@ which we will use later this session. No one can possibly learn all of these arguments, of course. So you will probably find yourself referring back to the manual page frequently. -**Examining the contents of other directories** +* * * * +**Short Exercise** + +1. Use the manual page for `ls` to guess what you would expect from +using the arguments `-l`, '-t', '-r' at the same time. +2. Try the following and see if you can figure out what they do, either by examining the results or consulting the manual page. + * `ls -lS` (equivalent to `ls -l -S`) + * `ls -lt` (equivalent to `ls -l -t`) + * `ls -1` (that's the number one, not a letter 'ell') + +* * * * + + +## Examining the contents of other directories By default, the `ls` commands lists the contents of the working directory (i.e. the directory you are in). You can always find the @@ -239,13 +248,21 @@ depending on what is most convenient. If we are in the home directory, it is more convenient to just enter the relative path since it involves less typing. +Over time, it will become easier for you to keep a mental note of the +structure of the directories that you are using hand how to quickly +navigate amongst them. + +* * * * +**Short Exercise** + Now, list the contents of the /bin directory. Do you see anything familiar in there? +* * * * ## Saving time with shortcuts, wild cards, and tab completion -**Shortcuts** +### Shortcuts There are some shortcuts which you should know about. Dealing with the home directory is very common. So, in the shell the tilde character, @@ -272,11 +289,12 @@ same thing, they print the contents of the current directory. This may seem like a useless shortcut right now, but we'll see when it is needed in a little while. -To summarize, the commands `ls ~`, `ls ~/.`, `ls ../../`, and `ls -/home/swc` all do exactly the same thing. These shortcuts are not -necessary, they are provided for your convenience. +To summarize, while you are in the `shell` directory, the commands +`ls ~`, `ls ~/.`, `ls ../../`, and `ls /home/swc` all do exactly the +same thing. These shortcuts are not necessary, they are provided for +your convenience. -**Our data set: Cochlear Implants** +### Our data set: Cochlear Implants A cochlear implant is a small electronic device that is surgically implanted in the inner ear to give deaf people a sense of @@ -313,7 +331,7 @@ commands to get this data into shape. By the end we would like to: If we can get through this example in the available time, we will move onto more advanced shell topics... -**Wild cards** +### Wild cards Navigate to the `~/boot-camps/shell/data/THOMAS` directory. This directory contains our hearing test data for THOMAS. If we type `ls`, @@ -362,7 +380,7 @@ navigating to a different directory. * * * * -**Tab Completion** +### Tab Completion Navigate to the home directory. Typing out directory names can waste a lot of time. When you start typing out the name of a directory, then @@ -386,7 +404,7 @@ enter `e`. You will see the name of every program that starts with an `e`. One of those is `echo`. If you enter `ec` you will see that tab completion works. -**Command History** +## Command History You can easily access previous commands. Hit the up arrow. Hit it again. You can step backwards through your command history. @@ -397,7 +415,7 @@ The down arrow takes your forwards in the command history. ^-R will do a reverse-search through your command history. This is very useful. -## Which program? ## +## Which program? Commands like `ls`, `rm`, `echo`, and `cd` are just ordinary programs on the computer. A program is just a file that you can *execute*. The @@ -717,7 +735,7 @@ learn to become proficient with the pipe and redirection operators: `|`, `>`, `>>`. -**A sorting example** +### A sorting example Let's create a file with some words to sort for the next example. We want to create a file which contains the following names: