10x Command Line-Fu
How to look cooler at Starbucks
How to understand more XKCD comics
https://github.com/epylinkn/itp-command-fu
Why am I here? Why practice command-fu?
4 You use the command line at work
4 You use it to bootstrap your code projects
4 Automating tasks you do frequently
4 Anthony seems like a cool guy I wonder what he has
to say
The command line is
incredibly expressive and
powerful. It can help you be
more productive and
automate mundane tasks.
Our Roadmap
4 standard unix bash commands
4 chaining, pipes and output redirection
4 alias, shell functions, and your first shell script
4 scripting with javascript
4 cron, .bashrc, and .bash_profile
4 homebrew - the package manager for OSX
/bin/bash
Mac's run Unix.
Developers love Unix.
Unix is awesome.
You can be awesome.
Standard unix bash commands
The basics
cd - change directory
ls - list files
pwd - current working directory
cp - copy
mv - move
mkdir - make directory
rm - remove
cat - concatenate
Standard unix bash commands
More advanced commands
say
history
head / tail
curl
time
watch
grep
find
xargs
ssh
Structure of a command
$ command --option option_argument x (y z ...)
tar czvf myTarball.tar.gz .
say cheese
Simple command to make terminal say something.
say why cant we be friends
Extra credit:
say --voice ?
say --voice "Bad News" The light you see at the end of the tunnel is the
headlamp of a fast approaching train.
history repeats itself
history
echo goodbye world
history
!-2
history
heads or tails
head camp.txt
head -n50 camp.txt
tail camp.txt
Extra Credit:
tail -f camp.txt
echo foo >> camp.txt
alias and your first shell script!
curly fries
curl itpcalendar.herokuapp.com/calendar
curl wttr.in
open -a "Google Chrome" http://wttr.in
curl -I ideas.ted.com
Extra Credit
curl -XPOST slack webhook
curl -o itp-calendar.html http://itp.nyu.edu/camp2016/session/238
# copy a cURL command from chrome inspector
Steal an entire site with wget
http://www.linuxjournal.com/content/downloading-
entire-web-site-wget
$ wget 
--recursive 
--no-clobber 
--page-requisites 
--html-extension 
--convert-links 
--restrict-file-names=windows 
--domains blankslate.io 
--no-parent 
blankslate.io
Chaining commands
false || echo "Oops, fail"
# => Oops fail
true || echo "Will not be printed"
# =>
true && echo "Things went well"
# => Things went well
false ; echo "This will always run"
# => This will always run
Output redirection
<
# The < will take and send the input from the file on the right to the
program on the left.
>
# The > takes the output of the command on the left, then writes it
to the file on the right.
>>
# The >> takes the output of the command on the left, then appends it
to the file on the right.
|
# The | takes the output from the command on the left, and "pipes" it to
the command on the right.
pipe
"pipe" the output of one command into the input of a
second command
cat ~/.bash_history | grep say | tail -n20
crontab -e
# Examples
*/1 * * * * say 'super duper'
# Use a login shell so that our ~/.bash_profile gets loaded
*/1 * * * * /bin/bash -lc "/Users/anthony/me/itp/command-fu/03-superbole.js"
HomebrewThe missing package manager for OS X
Some homebrew recommendations
Some homebrew recommendations:
brew update
brew install wget
wget https://cdn.rawgit.com/epylinkn/itp-command-fu/master/commandfu.pdf
brew install tree
tree .
brew install jq
curl itpcalendar.herokuapp.com/calendar | jq '.[].title'
# faster and more configurable command-line search
brew install the_silver_searcher
Brew Cask
brew install cask
brew cask info p5
brew cask install p5
open -a 'p5'
brew cask uninstall p5
brew cask search unity
brew cask install unity
Resources
4 https://github.com/jlevy/the-art-of-command-line
4 https://github.com/veltman/clmystery

10x Command Line Fu

  • 1.
    10x Command Line-Fu Howto look cooler at Starbucks How to understand more XKCD comics https://github.com/epylinkn/itp-command-fu
  • 3.
    Why am Ihere? Why practice command-fu? 4 You use the command line at work 4 You use it to bootstrap your code projects 4 Automating tasks you do frequently 4 Anthony seems like a cool guy I wonder what he has to say
  • 4.
    The command lineis incredibly expressive and powerful. It can help you be more productive and automate mundane tasks.
  • 5.
    Our Roadmap 4 standardunix bash commands 4 chaining, pipes and output redirection 4 alias, shell functions, and your first shell script 4 scripting with javascript 4 cron, .bashrc, and .bash_profile 4 homebrew - the package manager for OSX
  • 6.
    /bin/bash Mac's run Unix. Developerslove Unix. Unix is awesome. You can be awesome.
  • 7.
    Standard unix bashcommands The basics cd - change directory ls - list files pwd - current working directory cp - copy mv - move mkdir - make directory rm - remove cat - concatenate
  • 8.
    Standard unix bashcommands More advanced commands say history head / tail curl time watch grep find xargs ssh
  • 9.
    Structure of acommand $ command --option option_argument x (y z ...)
  • 11.
  • 12.
    say cheese Simple commandto make terminal say something. say why cant we be friends Extra credit: say --voice ? say --voice "Bad News" The light you see at the end of the tunnel is the headlamp of a fast approaching train.
  • 13.
    history repeats itself history echogoodbye world history !-2 history
  • 14.
    heads or tails headcamp.txt head -n50 camp.txt tail camp.txt Extra Credit: tail -f camp.txt echo foo >> camp.txt
  • 15.
    alias and yourfirst shell script!
  • 16.
    curly fries curl itpcalendar.herokuapp.com/calendar curlwttr.in open -a "Google Chrome" http://wttr.in curl -I ideas.ted.com Extra Credit curl -XPOST slack webhook curl -o itp-calendar.html http://itp.nyu.edu/camp2016/session/238 # copy a cURL command from chrome inspector
  • 17.
    Steal an entiresite with wget http://www.linuxjournal.com/content/downloading- entire-web-site-wget $ wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains blankslate.io --no-parent blankslate.io
  • 18.
    Chaining commands false ||echo "Oops, fail" # => Oops fail true || echo "Will not be printed" # => true && echo "Things went well" # => Things went well false ; echo "This will always run" # => This will always run
  • 19.
    Output redirection < # The< will take and send the input from the file on the right to the program on the left. > # The > takes the output of the command on the left, then writes it to the file on the right. >> # The >> takes the output of the command on the left, then appends it to the file on the right. | # The | takes the output from the command on the left, and "pipes" it to the command on the right.
  • 20.
    pipe "pipe" the outputof one command into the input of a second command cat ~/.bash_history | grep say | tail -n20
  • 21.
    crontab -e # Examples */1* * * * say 'super duper' # Use a login shell so that our ~/.bash_profile gets loaded */1 * * * * /bin/bash -lc "/Users/anthony/me/itp/command-fu/03-superbole.js"
  • 23.
  • 25.
    Some homebrew recommendations Somehomebrew recommendations: brew update brew install wget wget https://cdn.rawgit.com/epylinkn/itp-command-fu/master/commandfu.pdf brew install tree tree . brew install jq curl itpcalendar.herokuapp.com/calendar | jq '.[].title' # faster and more configurable command-line search brew install the_silver_searcher
  • 26.
    Brew Cask brew installcask brew cask info p5 brew cask install p5 open -a 'p5' brew cask uninstall p5 brew cask search unity brew cask install unity
  • 28.