|
12 | 12 | Librarians like handouts. To make a handout for this lesson, adapt/print from [https://librarycarpentry.org/lc-shell/reference](https://librarycarpentry.org/lc-shell/reference).
|
13 | 13 |
|
14 | 14 | ______
|
15 |
| -## 05-counting-mining.md |
| 15 | +## Differences between platforms |
16 | 16 |
|
17 |
| -This lesson notes that the `grep` flags `-o` and `-E` flag are not supported by Git Bash for Windows (see the callout 'Invalid option – o?'). Be prepared to manage these differences in shell behaviour between operating systems. |
| 17 | +Some of the commands used in this lesson behave differently depending on whether they are run on Git Bash for Windows, macOS X or Linux. Be prepared to manage these differences. Here are some examples from episode 5, "Counting and mining with the shell": |
| 18 | + |
| 19 | +- `grep -E` on macOS X acts like `grep -P` on other platforms. On Windows and Linux, `grep -E` is halfway between `grep -P` and `grep`: it only does what `grep` can do, but uses Perl-compatible syntax to do it. |
| 20 | + |
| 21 | +- The `grep` on Git Bash for Windows prior to version 2.19.0 (September 2018) did not support the `-o` flag. If someone gets an error "invalid option -- o", they are most likely trying to use one of these older versions. They should probably just skip the exercises that use it and upgrade later. |
| 22 | + |
| 23 | +- The episode uses `date +%Y-%m-%d` because `date -I` is not available on macOS X. |
| 24 | + |
| 25 | +- `date --help` is not available on macOS X so `man date` should be used instead. |
| 26 | + |
| 27 | +As noted below, you should avoid demonstrating any more options that only work on certain platforms. |
18 | 28 |
|
19 | 29 | _____
|
20 | 30 | # General notes on shell
|
|
31 | 41 | - is hard to troubleshoot, review, or improve
|
32 | 42 | - The Shell
|
33 | 43 | - Workflows can be automated through the use of shell scripts
|
34 |
| - - Built-in commands allow for easy data manipulation (e.g. sort, grep, etc.) |
| 44 | + - Built-in commands allow for easy data manipulation (e.g. `sort`, `grep`, etc.) |
35 | 45 | - Every step can be captured in the shell script and allow reproducibility and easy troubleshooting
|
36 | 46 |
|
37 | 47 | ## Overall
|
@@ -233,15 +243,7 @@ as long as learners using Windows do not run into roadblocks such as:
|
233 | 243 | Your particular shell may have extensions beyond POSIX that are not available
|
234 | 244 | on other machines, especially the default OSX bash and Windows bash emulators.
|
235 | 245 | For example, POSIX `ls` does not have an `--ignore=` or `-I` option, and POSIX
|
236 |
| - `head` takes `-n 10` or `-10`, but not the long form of `--lines=10`. For example, |
237 |
| - in Episode 5 when you are teaching grep there is a command in an exercise to prepend |
238 |
| - dates to filenames that will rely on the `-I` option: |
239 |
| - ~~~ |
240 |
| - $ grep -i revolution *.tsv > results/$(date -I)_JAi-revolution.tsv |
241 |
| - ~~~ |
242 |
| - The `-I` option for ISO dates may not work with the date command on Mac OSX like it does from BSD through GNU. |
243 |
| - If you or your students are on a Mac and `-I` option isn't available, then you could mimic the `-I` option |
244 |
| - like this: `echo $(date +%Y-%m-%d)` |
| 246 | + `head` takes `-n 10` or `-10`, but not the long form of `--lines=10`. |
245 | 247 |
|
246 | 248 |
|
247 | 249 | ## Windows
|
|
0 commit comments