Command Refactoring: Add alias

master
Mike Gerwitz 2019-03-10 23:18:05 -04:00
parent 2fcfd61291
commit 4f76c5c76f
Signed by: mikegerwitz
GPG Key ID: 8C917B7F5DC51BA2
1 changed files with 24 additions and 3 deletions

View File

@ -795,7 +795,7 @@ And that's why I've dragged you through this drawn-out example---to
** DEVOID A New Perspective [0/16]
*** Perspective Topics [12/13] :noexport:
*** Perspective Topics [13/13] :noexport:
- [X] What if I could walk away and get a coffee, play with the kids,
come back and have it done for me?
- Emphasize how users familiar with the tools I haven't yet mentioned
@ -828,6 +828,7 @@ And that's why I've dragged you through this drawn-out example---to
- [X] Now we have duplication: URL in two places
- Introduce variables
- [X] Eliminate the temporary file entirely using a pipe
- [X] Alias =fetch-url= for =wget -qO-=.
- [X] Introduce the Unix philosophy
- [ ] Now script discovering what pages contain a certain word [0/4]
- [ ] Mention previous example of being emailed a list of URLs. Rather
@ -1457,9 +1458,10 @@ But this is a hefty command to have to modify each time we want to try a
:BEAMER_env: fullframe
:END:
#+BEAMER: \begin{onlyenv}<5>
#+BEAMER: \begin{onlyenv}<6>
#+BEGIN_SRC sh
$ wget --quiet -O speakers.html \
https://libreplanet.org/2019/speakers/ \
&& grep --quiet 'free software' speakers.html \
@ -1470,6 +1472,7 @@ $ wget --quiet -O speakers.html \
#+BEAMER: \begin{onlyenv}<1>
#+BEGIN_SRC sh
$ URL=https://libreplanet.org/2019/speakers/
$ wget --quiet -O speakers.html \
"$URL" \
@ -1481,6 +1484,7 @@ $ wget --quiet -O speakers.html \
#+BEAMER: \begin{onlyenv}<2>
#+BEGIN_SRC sh
$ URL=https://libreplanet.org/2019/speakers/
$ wget -qO speakers.html \
"$URL" \
@ -1492,6 +1496,7 @@ $ wget -qO speakers.html \
#+BEAMER: \begin{onlyenv}<3>
#+BEGIN_SRC sh
$ URL=https://libreplanet.org/2019/speakers/
$ wget -qO - \
"$URL" \
@ -1501,14 +1506,27 @@ $ wget -qO - \
#+END_SRC
#+BEAMER: \end{onlyenv}
#+BEAMER: \begin{onlyenv}<4->
#+BEAMER: \begin{onlyenv}<4>
#+BEGIN_SRC sh
$ URL=https://libreplanet.org/2019/speakers/
$ wget -qO - "$URL" \
| grep -q 'free software' || echo "$URL" >> results.txt
#+END_SRC
#+BEAMER: \end{onlyenv}
#+BEAMER: \begin{onlyenv}<5->
#+BEGIN_SRC sh
$ alias fetch-url='wget -qO-'
$ URL=https://libreplanet.org/2019/speakers/ \
fetch-url "$URL" \
| grep -q 'free software' || echo "$URL" >> results.txt
#+END_SRC
#+BEAMER: \end{onlyenv}
@ -1562,6 +1580,9 @@ We then connect standard out of =wget= to the standard in of =grep= using a
Now that we've freed up some space,
let's reformat this slightly to be a bit more readable.
Any that =wget= command looks a bit cryptic.
How about we define an alias so that it looks a bit more friendly,
and then we can stop worrying about what it does?
And now here's the original command we started with,
and where we're at now.