Skip to content

Commit

Permalink
Merge pull request #73 from katrinleinweber/useful-file-names
Browse files Browse the repository at this point in the history
Improve filename examples & re-iterate use of $(date)
  • Loading branch information
dakane1 authored Jul 1, 2019
2 parents 6ec9991 + a3e7716 commit acd6575
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions _episodes/05-counting-mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,11 @@ $ grep -i revolution *.tsv
{: .bash}
This script looks in the defined files and prints any lines containing `revolution`
(without regard to case) to the shell. We add today's date to the filename using
[ISO format](https://en.wikipedia.org/wiki/ISO_8601) of `YYYY-MM-DD`.
(without regard to case) to the shell. We let the shell add today's date to the
filename:
~~~
$ grep -i revolution *.tsv > results/2016-07-19_JAi-revolution.tsv
$ grep -i revolution *.tsv > results/$(date -I)_JAi-revolution.tsv
~~~
{: .bash}
Expand All @@ -546,7 +546,7 @@ Thankfully, the `-w` flag instructs `grep` to look for whole words only,
giving us greater precision in our search.
~~~
$ grep -iw revolution *.tsv > results/2016-07-19_JAiw-revolution.tsv
$ grep -iw revolution *.tsv > results/$(date -I)_JAiw-revolution.tsv
~~~
{: .bash}
Expand All @@ -567,6 +567,17 @@ $ wc -l results/*.tsv
~~~
{: .output}
> ## Automatically adding a date prefix
> Notice how we didn't type the `YYYY-MM-DD` date ourselves, but let
> `date -I` do that mindless task for us. Find out about this option
> and the standard format that it uses.
>
> > ## Solution
> > Using `date --help` will show you that `-I` is short for [--iso-8601](https://en.wikipedia.org/wiki/ISO_8601), which essentially avoids the confusion between the European
> > and American date formats `DD.MM.YYYY` and `MM/DD/YYYY`.
> {: .solution}
{: .challenge}
Finally, we'll use the **regular expression syntax** covered earlier to search for similar words.
> ## Basic and extended regular expressions
Expand Down Expand Up @@ -661,23 +672,23 @@ Pair up with your neighbor and work on these exercises:
> ## Case insensitive search in select files
> Search for all case insensitive instances of that
> word in the 'America' and 'Africa' `.tsv` files in this directory. Print your results to a file `results/new.tsv`.
> word in the 'America' and 'Africa' `.tsv` files in this directory. Print your results to a file `results/hero.tsv`.
>
> > ## Solution
> > ~~~
> > $ grep -i hero *a.tsv > results/new.tsv
> > $ grep -i hero *a.tsv > results/hero.tsv
> > ~~~
> > {: .bash}
> {: .solution}
{: .challenge}
> ## Case insensitive search in select files (whole word)
> Search for all case insensitive instances of that whole word
> in the 'America' and 'Africa' `.tsv` files in this directory. Print your results to a file `results/new2.tsv`.
> in the 'America' and 'Africa' `.tsv` files in this directory. Print your results to a file `results/hero-i.tsv`.
>
> > ## Solution
> > ~~~
> > $ grep -iw hero *a.tsv > results/new2.tsv
> > $ grep -iw hero *a.tsv > results/hero-i.tsv
> > ~~~
> > {: .bash}
> {: .solution}
Expand Down

0 comments on commit acd6575

Please sign in to comment.