Skip to content

Commit c76410a

Browse files
authored
Merge pull request #137 from alex-ball/patch-8
Remove out-of-date warning about grep -o
2 parents 435e4aa + 1c590f8 commit c76410a

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

_episodes/05-counting-mining.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,6 @@ $ grep -iwEo 'fr[ae]nc[eh]' *.tsv
624624
~~~
625625
{: .bash}
626626
627-
> ## Invalid option -- o?
628-
> If you get an error message "invalid option -- o" when running the above command, it means you use a version of
629-
> `grep` that doesn't support the `-o` flag. This is for instance the case with the version of `grep` that comes with
630-
> Git Bash on Windows. Since the flag is not crucial to this lesson, please just relax and ignore the problem. If you
631-
> really needed the flag, however, you could have installed another version of `grep`. The situation for Windows users
632-
> also improves on Windows 10 with the new Bash on Windows.
633-
{: .callout}
634-
635627
Pair up with your neighbor and work on these exercises:
636628
637629
> ## Case sensitive search
@@ -733,8 +725,7 @@ Pair up with your neighbor and work on these exercises:
733725
> > correctly. You could use the `less` command for this.
734726
> >
735727
> > The `-o` flag means that only the ISSN itself is printed out, instead of the
736-
> > whole line. You can leave it out if it causes problems: see the callout box
737-
> > "Invalid option -- o?" above.
728+
> > whole line.
738729
> >
739730
> > If you came up with something more advanced, perhaps including word boundaries,
740731
> > please share your result in the collaborative document and give yourself a pat on the shoulder.
@@ -748,8 +739,6 @@ Pair up with your neighbor and work on these exercises:
748739
> In order for the 'uniq' command to only return unique values though, it needs to be used
749740
> with the 'sort' command. Try piping the output from the command in the last exercise
750741
> to `sort` and then piping these results to 'uniq' and then `wc -l` to count the number of unique ISSN values.
751-
> Note: This exercise requires the `-o` flag. See the callout box "Invalid option -- o?"
752-
> above.
753742
>
754743
> > ## Solution
755744
> > ~~~

_extras/guide.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,19 @@ ____
1212
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).
1313

1414
______
15-
## 05-counting-mining.md
15+
## Differences between platforms
1616

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.
1828

1929
_____
2030
# General notes on shell
@@ -31,7 +41,7 @@ _____
3141
- is hard to troubleshoot, review, or improve
3242
- The Shell
3343
- 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.)
3545
- Every step can be captured in the shell script and allow reproducibility and easy troubleshooting
3646

3747
## Overall
@@ -233,15 +243,7 @@ as long as learners using Windows do not run into roadblocks such as:
233243
Your particular shell may have extensions beyond POSIX that are not available
234244
on other machines, especially the default OSX bash and Windows bash emulators.
235245
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`.
245247
246248
247249
## Windows

0 commit comments

Comments
 (0)