Skip to content

Commit acd6575

Browse files
authored
Merge pull request #73 from katrinleinweber/useful-file-names
Improve filename examples & re-iterate use of $(date)
2 parents 6ec9991 + a3e7716 commit acd6575

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

_episodes/05-counting-mining.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,11 @@ $ grep -i revolution *.tsv
529529
{: .bash}
530530
531531
This script looks in the defined files and prints any lines containing `revolution`
532-
(without regard to case) to the shell. We add today's date to the filename using
533-
[ISO format](https://en.wikipedia.org/wiki/ISO_8601) of `YYYY-MM-DD`.
532+
(without regard to case) to the shell. We let the shell add today's date to the
533+
filename:
534534
535535
~~~
536-
$ grep -i revolution *.tsv > results/2016-07-19_JAi-revolution.tsv
536+
$ grep -i revolution *.tsv > results/$(date -I)_JAi-revolution.tsv
537537
~~~
538538
{: .bash}
539539
@@ -546,7 +546,7 @@ Thankfully, the `-w` flag instructs `grep` to look for whole words only,
546546
giving us greater precision in our search.
547547
548548
~~~
549-
$ grep -iw revolution *.tsv > results/2016-07-19_JAiw-revolution.tsv
549+
$ grep -iw revolution *.tsv > results/$(date -I)_JAiw-revolution.tsv
550550
~~~
551551
{: .bash}
552552
@@ -567,6 +567,17 @@ $ wc -l results/*.tsv
567567
~~~
568568
{: .output}
569569
570+
> ## Automatically adding a date prefix
571+
> Notice how we didn't type the `YYYY-MM-DD` date ourselves, but let
572+
> `date -I` do that mindless task for us. Find out about this option
573+
> and the standard format that it uses.
574+
>
575+
> > ## Solution
576+
> > 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
577+
> > and American date formats `DD.MM.YYYY` and `MM/DD/YYYY`.
578+
> {: .solution}
579+
{: .challenge}
580+
570581
Finally, we'll use the **regular expression syntax** covered earlier to search for similar words.
571582
572583
> ## Basic and extended regular expressions
@@ -661,23 +672,23 @@ Pair up with your neighbor and work on these exercises:
661672
662673
> ## Case insensitive search in select files
663674
> Search for all case insensitive instances of that
664-
> word in the 'America' and 'Africa' `.tsv` files in this directory. Print your results to a file `results/new.tsv`.
675+
> word in the 'America' and 'Africa' `.tsv` files in this directory. Print your results to a file `results/hero.tsv`.
665676
>
666677
> > ## Solution
667678
> > ~~~
668-
> > $ grep -i hero *a.tsv > results/new.tsv
679+
> > $ grep -i hero *a.tsv > results/hero.tsv
669680
> > ~~~
670681
> > {: .bash}
671682
> {: .solution}
672683
{: .challenge}
673684
674685
> ## Case insensitive search in select files (whole word)
675686
> Search for all case insensitive instances of that whole word
676-
> in the 'America' and 'Africa' `.tsv` files in this directory. Print your results to a file `results/new2.tsv`.
687+
> in the 'America' and 'Africa' `.tsv` files in this directory. Print your results to a file `results/hero-i.tsv`.
677688
>
678689
> > ## Solution
679690
> > ~~~
680-
> > $ grep -iw hero *a.tsv > results/new2.tsv
691+
> > $ grep -iw hero *a.tsv > results/hero-i.tsv
681692
> > ~~~
682693
> > {: .bash}
683694
> {: .solution}

0 commit comments

Comments
 (0)