Skip to content

Commit 502a311

Browse files
committed
Switches to double quotes in examples; fixes #5
1 parent 8ae6707 commit 502a311

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

ADVANCED.mkd

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ As an exercise, let's try to mimick some of the examples from the [jq tutorial](
99
1010
Get the last 5 commits from the gron repo:
1111
```
12-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5'
12+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5"
1313
json = [];
1414
json[0] = {};
1515
json[0].author = {};
@@ -23,9 +23,9 @@ json[4].sha = "91b204972e63a1166c9d148fbbfd839f8697f91b";
2323
json[4].url = "https://api.github.com/repos/tomnomnom/gron/commits/91b204972e63a1166c9d148fbbfd839f8697f91b";
2424
```
2525

26-
Extract just the first commit using `fgrep 'json[0]'`:
26+
Extract just the first commit using `fgrep "json[0]"`:
2727
```
28-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | fgrep 'json[0]'
28+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | fgrep "json[0]"
2929
json[0] = {};
3030
json[0].author = {};
3131
json[0].author.avatar_url = "https://avatars.githubusercontent.com/u/58276?v=3";
@@ -39,16 +39,16 @@ json[0].sha = "7da81e29c27241c0a5c2e5d083ddebcfcc525908";
3939
json[0].url = "https://api.github.com/repos/tomnomnom/gron/commits/7da81e29c27241c0a5c2e5d083ddebcfcc525908";
4040
```
4141

42-
Get just the committer's name and the commit message using `egrep '(committer.name|commit.message)'`:
42+
Get just the committer's name and the commit message using `egrep "(committer.name|commit.message)"`:
4343
```
44-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | fgrep 'json[0]' | egrep '(committer.name|commit.message)'
44+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | fgrep "json[0]" | egrep "(committer.name|commit.message)"
4545
json[0].commit.committer.name = "Tom Hudson";
4646
json[0].commit.message = "Adds 0.1.7 to changelog";
4747
```
4848

4949
Turn the result back into JSON using `gron --ungron`:
5050
```
51-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | fgrep 'json[0]' | egrep '(committer.name|commit.message)' | gron --ungron
51+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | fgrep "json[0]" | egrep "(committer.name|commit.message)" | gron --ungron
5252
[
5353
{
5454
"commit": {
@@ -63,10 +63,10 @@ Turn the result back into JSON using `gron --ungron`:
6363

6464
gron preserves the location of values in the JSON, but you can use `sed` to remove keys from the path:
6565
```
66-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | fgrep 'json[0]' | egrep '(committer.name|commit.message)' | sed -r 's/(commit|committer)\.//g'
66+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | fgrep "json[0]" | egrep "(committer.name|commit.message)" | sed -r "s/(commit|committer)\.//g"
6767
json[0].name = "Tom Hudson";
6868
json[0].message = "Adds 0.1.7 to changelog"
69-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | fgrep 'json[0]' | egrep '(committer.name|commit.message)' | sed -r 's/(commit|committer)\.//g' | gron --ungron
69+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | fgrep "json[0]" | egrep "(committer.name|commit.message)" | sed -r "s/(commit|committer)\.//g" | gron --ungron
7070
[
7171
{
7272
"message": "Adds 0.1.7 to changelog",
@@ -75,9 +75,9 @@ json[0].message = "Adds 0.1.7 to changelog"
7575
]
7676
```
7777

78-
Removing the `fgrep 'json[0]'` from the pipeline means we do the same for all commits:
78+
Removing the `fgrep "json[0]"` from the pipeline means we do the same for all commits:
7979
```
80-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | egrep '(committer.name|commit.message)' | sed -r 's/(commit|committer)\.//g' | gron --ungron
80+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | egrep "(committer.name|commit.message)" | sed -r "s/(commit|committer)\.//g" | gron --ungron
8181
[
8282
{
8383
"message": "Adds 0.1.7 to changelog",
@@ -92,7 +92,7 @@ Removing the `fgrep 'json[0]'` from the pipeline means we do the same for all co
9292

9393
To include the `html_url` key for each commit's parents, all we need to do is add `parents.*html_url` into our call to `egrep`:
9494
```
95-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | egrep '(committer.name|commit.message|parents.*html_url)' | sed -r 's/(commit|committer)\.//g'
95+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | egrep "(committer.name|commit.message|parents.*html_url)" | sed -r "s/(commit|committer)\.//g"
9696
json[0].name = "Tom Hudson";
9797
json[0].message = "Adds 0.1.7 to changelog";
9898
json[0].parents[0].html_url = "https://github.com/tomnomnom/gron/commit/48aba5325ece087ae24ab72684851cbe77ce8311";
@@ -102,9 +102,9 @@ json[1].parents[0].html_url = "https://github.com/tomnomnom/gron/commit/3eca8bf5
102102
...
103103
```
104104

105-
To make the structure more like that in the final example in the `jq` tutorial, we can use `sed -r 's/\.html_url//'` to remove the `.html_url` part of the path:
105+
To make the structure more like that in the final example in the `jq` tutorial, we can use `sed -r "s/\.html_url//"` to remove the `.html_url` part of the path:
106106
```
107-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | egrep '(committer.name|commit.message|parents.*html_url)' | sed -r 's/(commit|committer)\.//g' | sed -r 's/\.html_url//'
107+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | egrep "(committer.name|commit.message|parents.*html_url)" | sed -r "s/(commit|committer)\.//g" | sed -r "s/\.html_url//"
108108
json[0].name = "Tom Hudson";
109109
json[0].message = "Adds 0.1.7 to changelog";
110110
json[0].parents[0] = "https://github.com/tomnomnom/gron/commit/48aba5325ece087ae24ab72684851cbe77ce8311";
@@ -116,7 +116,7 @@ json[1].parents[0] = "https://github.com/tomnomnom/gron/commit/3eca8bf5e07151f07
116116

117117
And, of course, the statements can be turned back into JSON with `gron --ungron`:
118118
```
119-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=5' | egrep '(committer.name|commit.message|parents.*html_url)' | sed -r 's/(commit|committer)\.//g' | sed -r 's/\.html_url//' | gron --ungron
119+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=5" | egrep "(committer.name|commit.message|parents.*html_url)" | sed -r "s/(commit|committer)\.//g" | sed -r "s/\.html_url//" | gron --ungron
120120
[
121121
{
122122
"message": "Adds 0.1.7 to changelog",

README.mkd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gron transforms JSON into discrete assignments to make it easier to `grep` for w
77
It eases the exploration of APIs that return large blobs of JSON but have terrible documentation.
88

99
<pre>
10-
▶ <b>gron</b> 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=1' | fgrep 'commit.author'
10+
▶ <b>gron</b> "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" | fgrep "commit.author"
1111
json[0].commit.author = {};
1212
json[0].commit.author.date = "2016-07-02T10:51:21Z";
1313
json[0].commit.author.email = "[email protected]";
@@ -16,7 +16,7 @@ json[0].commit.author.name = "Tom Hudson";
1616

1717
gron can work backwards too, enabling you to turn your filtered data back into JSON:
1818
<pre>
19-
▶ gron 'https://api.github.com/repos/tomnomnom/gron/commits?per_page=1' | fgrep 'commit.author' | <b>gron --ungron</b>
19+
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" | fgrep "commit.author" | <b>gron --ungron</b>
2020
[
2121
{
2222
"commit": {

0 commit comments

Comments
 (0)