From: Matt Davis Date: Mon, 13 May 2013 18:25:25 +0000 (-0700) Subject: Changing 'git clone' URL in shell README to the read-only git:// URL. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e3a10f8946b2a74c9fc60b7996dbd44c3d57628a;p=swc-workshop.git Changing 'git clone' URL in shell README to the read-only git:// URL. It had been showing the HTTPS URL but about 50% of the time that would ask people for their usernames and passwords even though they just wanted to clone. The read-only URL should never involve username/password stuff. --- diff --git a/shell/Readme.md b/shell/Readme.md index d2c55ad..bb9592b 100644 --- a/shell/Readme.md +++ b/shell/Readme.md @@ -10,6 +10,7 @@ with a keyboard instead of controlling graphical user interfaces (GUIs) with a mouse/keyboard combination. Use a browser to open the tutorial on github, located at: + https://github.com/USERNAME/boot-camps/tree/YYYY-MM-PLACE Click on the directory named `shell`. @@ -17,13 +18,13 @@ Click on the directory named `shell`. A *terminal* is a program you run that gives you access to the shell. There are many different terminal programs that vary across operating systems. - + There are many reasons to learn about the shell. In my opinion, the -most important reasons are that: +most important reasons are that: 1. It is very common to encounter the shell and command-line-interfaces in scientific computing, so you will - probably have to learn it eventually + probably have to learn it eventually 2. The shell is a really powerful way of interacting with your computer. GUIs and the shell are complementary - by knowing both @@ -50,7 +51,7 @@ by manipulating some experimental data from a hearing test. To get the data for this test, you will need internet access. Just enter the command: - git clone -b YYYY-MM-PLACE https://github.com/USERNAME/boot-camps.git + git clone -b YYYY-MM-PLACE --single-branch git://github.com/swcarpentry/boot-camps.git 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 @@ -73,7 +74,7 @@ to other programs. Let's learn how to move around the file system using command line programs. This is really easy to do using a GUI (just click on things). Once you learn the basic commands, you'll see that it is -really easy to do in the shell too. +really easy to do in the shell too. First we have to know where we are. The program `pwd` (print working directory) tells you where you are sitting in the directory tree. The @@ -88,7 +89,7 @@ directory where they have full access to do whatever they want. In this case, the `pwd` command tells us that we are in the `/home/swc` 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`. +command `whoami`. ## File Types @@ -105,7 +106,7 @@ command: Then list the contents of the directory again. You should see that a new entry, called `testfile`, exists. It is colored white meaning that it is a file, as opposed to a directory. The `touch` command just -creates an empty file. +creates an empty file. Some terminals will not color the directory entries in this very convenient way. In those terminals, use `ls -F` instead of `ls`. The @@ -259,7 +260,7 @@ navigate amongst them. Now, list the contents of the /bin directory. Do you see anything familiar in there? -* * * * +* * * * ## Saving time with shortcuts, wild cards, and tab completion @@ -274,7 +275,7 @@ directory, then enter the command: This prints the contents of your home directory, without you having to type the full path. The shortcut `..` always refers to the directory -above your current directory. Thus: +above your current directory. Thus: ls .. @@ -398,7 +399,7 @@ The shell will fill in the rest of the directory name for When you hit the first tab, nothing happens. The reason is that there are multiple directories in the home directory which start with `s`. Thus, the shell does not know which one to fill in. When you hit -tab again, the shell will list the possible choices. +tab again, the shell will list the possible choices. Tab completion can also fill in the names of programs. For example, enter `e`. You will see the name of every program that @@ -407,9 +408,9 @@ will see that tab completion works. ## Command History -You can easily access previous commands. Hit the up arrow. -Hit it again. You can step backwards through your command history. -The down arrow takes your forwards in the command history. +You can easily access previous commands. Hit the up arrow. +Hit it again. You can step backwards through your command history. +The down arrow takes your forwards in the command history. ^-C will cancel the command you are writing, and give you a fresh prompt. @@ -436,13 +437,13 @@ then you could repeat command #260 by simply entering: (that's an exclamation mark). -* * * * +* * * * **Short Exercise** 1. Find the line number in your history for the last exercise (listing files in /bin) and reissue that command. -* * * * +* * * * ## Which program? @@ -476,7 +477,7 @@ on environment variables later. Notice that a list of directories, separated by colon characters, is listed. These are the places the shell looks for programs to run. If your program is not in this list, then an error is printed. The shell ONLY checks in the places listed -in the `PATH` environment variable. +in the `PATH` environment variable. Navigate to the `shell` directory and list the contents. You will notice that there is a program (executable file) called `hello` in @@ -521,7 +522,7 @@ This prints out the contents of the `ex_data.txt` file. If you enter: It will print out the contents of `ex_data.txt` twice. `cat` just takes a list of file names and writes them out one after another (this -is where the name comes from, `cat` is short for concatenate). +is where the name comes from, `cat` is short for concatenate). * * * * **Short Exercises** @@ -542,12 +543,12 @@ case. Enter the following command: less ~/boot-camps/shell/dictionary.txt `less` opens the file, and lets you navigate through it. The commands -are identical to the `man` program. +are identical to the `man` program. **Some commands in `less`** | key | action | -| ------- | ---------- | +| ------- | ---------- | | "space" | to go forward | | "b" | to go backwarsd | | "g" | to go to the beginning | @@ -574,7 +575,7 @@ using "/" as well! Use the commands we've learned so far to figure out how to search in reverse while using `less`. -* * * * +* * * * ## Redirection @@ -648,7 +649,7 @@ the backup file now: rm /tmp/all_data_backup The `mkdir` command is used to make a directory. Just enter `mkdir` -followed by a space, then the directory name. +followed by a space, then the directory name. * * * * **Short Exercise** @@ -679,7 +680,7 @@ For each of the files indicated, `wc` has printed a line with three numbers. The first is the number of lines in that file. The second is the number of words. Finally, the total number of characters is indicated. The final line contains this information summed over all of -the files. Thus, there were 10445 characters in total. +the files. Thus, there were 10445 characters in total. Remember that the `Bert/*` and `gerdal/*4*` files were merged into the `all_data` file. So, we should see that `all_data` contains @@ -764,7 +765,7 @@ printed back at you. The CONTROL+d keyboard shortcut inserts an *end-of-file* character. It is sort of the standard way of telling the program "I'm done entering data". The `|` character is replaces the data from the keyboard with data from another command. You can string -all sorts of commands together using the pipe. +all sorts of commands together using the pipe. The philosophy behind these command line programs is that none of them really do anything all that impressive. BUT when you start chaining @@ -837,7 +838,7 @@ Hint: To print the smallest file, use: wc Bert/* | sort -k 3 -n | head -n 1 -* * * * +* * * * Printing the smallest file seems pretty useful. We don't want to type out that long command often. Let's create a simple script, a simple @@ -856,7 +857,7 @@ Then enter the following text: Now, `cd` into the `Bert` directory and enter the command `../smallest`. Notice that it says permission denied. This happens because we haven't told the shell that this is an executable -file. If you do `ls -l ../smallest`, it will show you the permissions on +file. If you do `ls -l ../smallest`, it will show you the permissions on the left of the listing. Enter the following commands: @@ -871,7 +872,7 @@ you enter: ls -l ../smallest -You will see that the file name is green and the permissions have changed. +You will see that the file name is green and the permissions have changed. Congratulations, you just created your first shell script! # Searching files @@ -886,7 +887,7 @@ conducted: grep Range * -* * * * +* * * * **Short Exercise** Create an executable script called `smallestrange` in the `data` @@ -894,7 +895,7 @@ directory, that is similar to the `smallest` script, but prints the file containing the file with the smallest Range. Use the commands `grep`, `sort`, and `tail` to do this. -* * * * +* * * * # Finding files @@ -931,19 +932,19 @@ A faster way to do this is to use the `xargs` command: find . -type f -print | xargs grep Volume -`find` generates a list of all the files we are interested in, -then we pipe them to `xargs`. `xargs` takes the items given to it +`find` generates a list of all the files we are interested in, +then we pipe them to `xargs`. `xargs` takes the items given to it and passes them as arguments to `grep`. `xargs` generally only creates a single instance of `grep` (or whatever program it is running). -* * * * +* * * * **Short Exercise** Navigate to the `data` directory. Use one `find` command to perform each of the operations listed below (except number 2, which does not require a `find` command): -1. Find any file whose name is "NOTES" within `data` and delete it +1. Find any file whose name is "NOTES" within `data` and delete it 2. Create a new directory called `cleaneddata` @@ -966,9 +967,9 @@ following: Redo exercise 4, except rename only the files which do not already end in `.txt`. You will have to use the `man` command to figure out how to -search for files which do not match a certain name. +search for files which do not match a certain name. -* * * * +* * * *