Skip to content

Commit

Permalink
[custom] fix lesson contents
Browse files Browse the repository at this point in the history
  • Loading branch information
zkamvar authored and Carpentries Apprentice committed May 8, 2023
1 parent 5620187 commit cad531c
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 65 deletions.
1 change: 0 additions & 1 deletion episodes/02-navigating-the-filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ us right back to the home directory, the place where we started.**

To switch back and forth between two directories use `cd -`.


::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::: challenge
Expand Down
8 changes: 0 additions & 8 deletions episodes/03-working-with-files-and-folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ first point of difference, after which we can add more characters, and
try using tab again. We would encourage using this method throughout
today to see how it behaves (as it saves loads of time and effort!).


::::::::::::::::::::::::::::::::::::::::::::::::::

### Reading files
Expand Down Expand Up @@ -188,7 +187,6 @@ up arrow to cycle through your previous commands. The down arrow cycles back
toward your most recent command. This is another important labour-saving
function and something we'll use a lot.


::::::::::::::::::::::::::::::::::::::::::::::::::

Press the up arrow until you get to the `head 829-0.txt` command. Add a space
Expand Down Expand Up @@ -246,7 +244,6 @@ As an exception, if a wildcard expression does not match any file, Bash
will pass the expression as a parameter to the command as it is. For example
typing `ls *.pdf` results in an error message that there is no file called \*.pdf.


::::::::::::::::::::::::::::::::::::::::::::::::::

<!-- Timing: Spent 75 minutes to get here -->
Expand Down Expand Up @@ -361,8 +358,6 @@ them. We'll get back to that.)

- The `?` wildcard matches the regular expression `.` (a dot)
- The `*` wildcard matches the regular expression `.*`



:::::::::::::::::::::::::

Expand All @@ -385,7 +380,6 @@ called `history.txt` that you can later edit. To recall a command from history,
`history`. Note the command number, e.g. 2045. Recall the command by entering
`!2045`. This will execute the command.


::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::: challenge
Expand Down Expand Up @@ -418,8 +412,6 @@ to output text to the screen, such as the current status of a script.
Moreover, you just used a shell variable for the first time, which can be used to temporarily store information,
that you can reuse later on. It will give many opportunities from the moment you start writing automated scripts.



:::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down
13 changes: 2 additions & 11 deletions episodes/04-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exercises: 10

::::::::::::::::::::::::::::::::::::::::::::::::::

### Writing a Loop
## Writing a Loop

**Loops** are key to productivity improvements through automation as they allow us to execute
commands repetitively. Similar to wildcards and tab completion, using loops also reduces the
Expand Down Expand Up @@ -88,7 +88,6 @@ Therefore, it's best and generally safer to use `"$..."` unless
you are absolutely sure that no elements with white-space can ever
enter your loop variable (such as in [episode 5](05-counting-mining.md)).


::::::::::::::::::::::::::::::::::::::::::::::::::

In this example, the list is four filenames: 'a.txt', 'b.txt', 'c.txt', and 'd.txt'
Expand All @@ -110,7 +109,6 @@ typing in our loop. The second prompt, `>`, is different to remind
us that we haven't finished typing a complete command yet. A semicolon, `;`,
can be used to separate two commands written on a single line.


::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::: callout
Expand All @@ -132,7 +130,6 @@ the shell to redirect output.
If *you* type `$` in the shell, it is an instruction from you to
the shell to get the value of a variable.


::::::::::::::::::::::::::::::::::::::::::::::::::

We have called the variable in this loop `filename`
Expand Down Expand Up @@ -193,8 +190,6 @@ you've been using for the lesson and by using the text editor of your choice (e.
file, make sure it has the extension **.sh** (e.g. `my_first_bash_script.sh`). When you've done this, you can run the
Bash script by typing the command bash and the file name via the command line (e.g. `bash my_first_bash_script.sh`).

::::::::::::::::::::::::::::::::::: language-bash

```
#!/bin/bash
# This script loops through .txt files, returns the file name, first line, and last line of the file
Expand All @@ -206,11 +201,7 @@ do
done
```


Download/copy [my\_first\_bash\_script.sh](https://raw.githubusercontent.com/LibraryCarpentry/lc-shell/gh-pages/files/my_first_bash_script.sh). For more on Bash scripts, see [Bash Scripting Tutorial - Ryans Tutorials](https://ryanstutorials.net/bash-scripting-tutorial/).


::::::::::::::::::::::::::::::::::::::::::::::::::
Download/copy [my\_first\_bash\_script.sh](files/my_first_bash_script.sh). For more on Bash scripts, see [Bash Scripting Tutorial - Ryans Tutorials](https://ryanstutorials.net/bash-scripting-tutorial/).

::::::::::::::::::::::::::::::::::::::::::::::::::

Expand Down
9 changes: 0 additions & 9 deletions episodes/05-counting-mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ files, say, there is no `CSV` program, just lots and lots of programs that
support the format, including Excel by the way.), and you wouldn't have any
problems opening a 40 year old file today if you came across one.


::::::::::::::::::::::::::::::::::::::::::::::::::

<!-- hm, reminds me of MARC -->
Expand Down Expand Up @@ -276,7 +275,6 @@ lines of text to standard output can be combined with every other program that
behaves this way as well. You can and should write your programs this way so that
you and other people can put those programs into pipes to multiply their power.


::::::::::::::::::::::::::::::::::::::::::::::::::

<!-- Copied from https://swcarpentry.github.io/shell-novice/04-pipefilter/ -->
Expand Down Expand Up @@ -382,8 +380,6 @@ To check the contents, you could also use `less` or many other commands.
Beware that `>` will happily overwrite an existing file without warning you,
so please be careful.



:::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down Expand Up @@ -492,7 +488,6 @@ print the matching lines.

A string is a sequence of characters, or "a piece of text".


::::::::::::::::::::::::::::::::::::::::::::::::::

Press the up arrow once in order to cycle back to your most recent action.
Expand Down Expand Up @@ -573,7 +568,6 @@ This way of writing dates is so common that on some platforms (not macOS X)
you can get the same result by typing `$(date -I)` instead of
`$(date "+%Y-%m-%d")`.


::::::::::::::::::::::::::::::::::::::::::::::::::

However, if we look at this file, it contains every instance of the
Expand Down Expand Up @@ -624,8 +618,6 @@ You might also see that `-I` is short for
essentially avoids the confusion between the European
and American date formats `DD.MM.YYYY` and `MM/DD/YYYY`.



:::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::
Expand All @@ -646,7 +638,6 @@ most advanced regular expressions your version of `grep` supports (`-E` flag on
macOS X, `-P` on most other platforms) or when doing something more complex
than searching for a plain string.


::::::::::::::::::::::::::::::::::::::::::::::::::

The regular expression 'fr[ae]nc[eh]' will match "france", "french", but also "frence" and "franch".
Expand Down
26 changes: 12 additions & 14 deletions episodes/06-free-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ If so you will need to use a Bash script; we encountered these at the end of epi

As a reminder, use the text editor of your choice to write a file that looks like this:

> ```bash
> #!/bin/bash
> # This script removes quote marks from gulliver-clean.txt and saves the result as gulliver-noquotes.txt
> (replace this line with your solution)
> ```
>
> Save the file as `remove-quotes.sh` and run it from the command line like this:
>
> ```bash
> bash remove-quotes.sh
> ```
```bash
#!/bin/bash
# This script removes quote marks from gulliver-clean.txt and saves the result as gulliver-noquotes.txt
(replace this line with your solution)
```

Save the file as `remove-quotes.sh` and run it from the command line like this:

```bash
bash remove-quotes.sh
```

::::::::::::::: solution

Expand All @@ -187,8 +187,6 @@ sed -Ee 's/[""‘']//g' gulliver-clean.txt > gulliver-noquotes.txt
If this doesn't work for you, you might need to check whether your text editor can
save files using the UTF-8 encoding.

:::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down Expand Up @@ -350,7 +348,7 @@ First we wil remove all the html tags. Type and run:
$ sed -e 's/<[^>]*>//g' diary-noheadfoot.txt > diary-notags.txt
```
Here we are using a regular expression (see the [Library Carpentry regular expression lesson](https://librarycarpentry.org/lc-data-intro/01-regular-expressions/) to find all valid html tags (anything within angle brackets) and delete them). This is a complex regular expression, so don't worry too much about how it works! The script also requires the use of both the output redirect `>` we have seen and the input redirect `<` we haven't seen.
Here we are using a regular expression (see the [Library Carpentry regular expression lesson](https://librarycarpentry.org/lc-data-intro/01-regular-expressions) to find all valid html tags (anything within angle brackets) and delete them). This is a complex regular expression, so don't worry too much about how it works! The script also requires the use of both the output redirect `>` we have seen and the input redirect `<` we haven't seen.
We're going to start by using the `tr` command, used for translating or
deleting characters. Type and run:
Expand Down
19 changes: 19 additions & 0 deletions episodes/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
site: sandpaper::sandpaper_site
---

This Library Carpentry lesson introduces librarians to the Unix Shell.
At the conclusion of the lesson you will: describe the basics of the Unix shell;
explain why and how to use the command line;
use shell commands to work with directories and files;
use shell commands to find and manipulate data.

:::::::::::::::::::::::::::::::::::::::::: prereq

## Prerequisites

To complete this lesson, you will need a Unix-like shell environment -see [Setup](learners/setup.md). You will also need to download the file **[shell-lesson.zip](episodes/data/shell-lesson.zip)** from GitHub to your *desktop* and extract it there (once you have unzipped/extracted the file, you should end up with a folder called "shell-lesson").

::::::::::::::::::::::::::::::::::::::::::::::::::


43 changes: 21 additions & 22 deletions learners/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,30 @@ If you encounter issues, the Carpentries maintains a [Configuration Problems and

::::::::::::::::::::::::::::::::::::::::::::::::::

> ## Data Files
>
> You need to download some files to follow this lesson:
>
> 1. Download [shell-lesson.zip](data/shell-lesson.zip) and move the file to your Desktop.
> 2. Unzip/extract the file (ask your instructor if you need help with this step). You should end up with a new folder called `shell-lesson` on your Desktop.
> 3. Open the terminal and type `ls` followed by the <kbd>enter</kbd> key.
>
> ```bash
> $ ls
> ```
>
> You should see a list of files and folders in your current directory.
> 4\. Then type:
>
> ```
> $ pwd
> ```
:::::::::::::::::::::::::::::::::::::::::: prereq

## Data Files

You need to download some files to follow this lesson:

1. Download [shell-lesson.zip](data/shell-lesson.zip) and move the file to your Desktop.
2. Unzip/extract the file (ask your instructor if you need help with this step). You should end up with a new folder called `shell-lesson` on your Desktop.
3. Open the terminal and type `ls` followed by the <kbd>enter</kbd> key.

```bash
$ ls
```
>{: .language-bash}
> This command will show you where you are in your file system, which should now be your home directory. In the lesson, you will find out more about the commands `ls`, `pwd` and how to work with the data in `shell-lesson` folder.
{: .prereq}

[template]: {{site.workshop_repo}}
You should see a list of files and folders in your current directory.
4\. Then type:

```bash
$ pwd
```

This command will show you where you are in your file system, which should now be your home directory. In the lesson, you will find out more about the commands `ls`, `pwd` and how to work with the data in `shell-lesson` folder.


::::::::::::::::::::::::::::::::::::::::::::::::::


0 comments on commit cad531c

Please sign in to comment.