um welcome to bashes magic no it's not
you get this joke probably not the right
talk for you you saw it time to go no
there another rooms you don't have no
idea what this means you are definitely
the right place so quickly I'm Dwayne
Pantheon I'll get back to
that in a minute
I have been the last year fall in love
with crochet it's like the really fun
Amy to do so if you're talked about
crochet please let's talk about it I
make scarves and hats and whatnot in
octopus's I love love comics as we'll
talk about those and karaoke we karaoke
last night why not tonight
every night's karaoke night all my
slides for this talk and everything I'll
ever give in my life is probably over
our website MC Dwayne comm that's
actually where you should go right now
get these slides up if you go to my
websites the very top link will take you
to the description and there's a link to
the slides in there the slides are
actually open for comment from anyone so
I would love your feedback this is the
second time I've given this talk and I
desperately need feedback to make it
better for the future before I move on
quick talk about Pantheon um who here is
familiar with Pantheon that's pretty
much the whole room but for those of you
who might not be there wasn't on Drupal
TV or YouTube later Pantheon is a
website operations platform that helps
people that are operating a web site
meaning the developers the designers the
project managers the stakeholders you
had better communication strategies I
always like to quote Kelly Albright
DevOps is not about tools it's about
communication and we really do help with
that problem and we'd love to talk to
you about automation and that's really
one of the reasons I'm doing this but
before I go on and talk about why this
is automation ultimately I just want to
quit a quick poll of people in the room
all right everybody's your hand if you
came into this room because you saw the
talk description and said I want to see
that talk that's everybody good we're a
hundred percent almost hundred percent
he doesn't raise their hand now here is
a developer full-time that's all they do
is develop who here is a designer who
here is a content a content creator
writer editor yeah believer and I think
you're gonna get a lot out of this talk
is there any business people in here
sales folks otherwise
good good actually this is super helpful
for folks like you as well it's helpful
for everybody who here this is like the
ultimate who here owns a computer it's
still the person on the computer that
same person for those of you at home not
gonna call any names I have a hundred
and fourteen slides ish no we're not
gonna go through every single one on
today and then explain them all in
detail and I'm definitely not gonna read
them to you but if you are a novice and
you have no idea what bashes just sit
there take some notes I highly encourage
you to take notes it's the best way to
acquire new skills I think is to take
notes first if you know a little bit
about Bosch open up your terminal let's
fly along at home about halfway through
it's gonna kick in where you can just
start playing along at home and you
might pick up a few things and if you
are an advanced user and you know what
that says just do that if you don't know
what that says cut yourself in the one
would love categories slide 106 and
below is for you and we should have some
fun with this so bash we're here to talk
about the magic that is bash and we
think of magic we think of well fun like
card tricks and kids birthday parties
and wonderful stuff or we think of
terrifying things that are really
complex that if you know what you're
doing with it this is a really cool card
you can win a game with this card it's
actually legal in current turn
tournament play but if you don't know
what this is it's just an evil looking
thing that's kind of scary it's a little
bit overwhelming amount of text like
what on earth do I do with this I don't
know what most of that means looks cool
but it's also looks scary
when husbands talk together for business
users in their room actually we bounced
a bunch of ideas off of one of my
colleagues heads and Ben who was in
sales he said you know what this thing
you're describing kind of sounds like
the whole point open source to me like
smart people leveraging smart tools and
intelligent way they're signing together
and it was like this epiphany moment for
me is like if I can make everyone get
that then man I can totally win this so
that's where I kind of based the rest of
this off of because we are terrified of
things we don't understand it is human
nature if we don't understand a thing no
matter how benign it is no matter how
ultimately you're cute it is we're gonna
be like this kid and we're gonna freak
the heck out especially when you hear
stories like this now this isn't a true
story turns out this was a giant hoax so
don't worry this didn't actually happen
but I have seen in production enough of
my life people take down entire racks of
things my accident people accidentally
wipe out their entire project and I have
to start over from the last time they
saved there's a lot of horrible stories
where you hear it's like oh my goodness
bash is terrifying bash is scary it is
the most intimidating user experience in
the world there's just a cursor and you
have to know what to do with we're all
terrified of breaking our machines we're
all and we all set up our machines to do
exactly what we want them to do and
sometimes it takes us weeks months then
we've been using the same machine for
years for a reason not because it's the
best machine on the market but because
it's set up the exact way we want it
we're terrified of changing that because
we know the time investment it took and
who knows how to go through those GUI
screens again who here's our setup ma'am
all isn't that fun to make it agree with
your PHP and my sequel version no no
that's the terrified so I use lando but
every single developer I've ever talked
to that uses bash says yeah there's a
legitimate underlying fear there sure
it's powerful but don't be afraid of it
just embrace the thing
and it's easy to say this it is so easy
to say to someone that doesn't know what
they're doing this scares like just
don't be afraid but how many times does
that ever work for you when you're
terrified if someone says just don't be
afraid don't worry about the giant
spinning blades they're they're fine but
here's the amazing part you have at your
disposal a more RAW processing power
than we had when we put astronauts on
the moon by like a 10,000 factor an
iPhone 5 has 13 hundred percent more
processing power than all of the Apollo
missions had put together you're talking
about Bosch which is close to 40 years
old and like the technology it's doing
how could have you gotten on like Mac OS
R on the iOS just in the last decade how
much better did this tool get over that
last same period of time how many things
can your computer do that you currently
can't access turns out it's almost
infinite because once you understand
like what this does your machines yours
and this that's not the true sense in
nature of open source that I have the
right to look at the code and manipulate
the code but if I don't understand the
machine that it's running on I'd only
get you so far so you can unlock all of
the potential of your machine through
this wonderful wonderful little thing
called bash but why would I know in this
room actually care to do bash sure
that's great that's a wonderful speech
like it's powerful wonderful I want to
empower everyone in the world and I
really do but I work with a lot of
developers in the world I train a lot of
people at Pantheon on Pantheon and I
watch people go through GUI screens to
do everything and it's just slow and I'm
like disabled of your life this is how
you do all these things and there's
nothing wrong with the GUI I will never
ever talk down about a GUI in general
but that GUI was built by a developer
and the developer has a specific goal
with it GUI in mind not to let you do
everything that tool could possibly do
that would be a giant laundry list of
click boxes and buttons and whatnot
their goal is to make the interface
intuitive and
easy to do the things that you probably
wanted to do and that's awesome but it
can do so much more and it's also really
slow to go in and click buttons who here
really likes the CMI click button
interface and how fast it is that's
single hand drush is so much faster to
get your config imported it's just
ridiculously much faster it's like I
don't even know why we have a GUI
honestly it's just that much faster but
it's not just that it's one individual
button click it's exactly to do the same
button clicks over and over and over and
over and over again real life story I do
a weekly demo of Pantheon about half the
weeks of the year and I have to open 8
tabs for it and at the end of it I have
to do a like 6 cleanup steps to put
myself back to a proper state so I can
do that demo again and I got sick of
doing it so I have to batch scripts what
opens one closes the clothes because
there's only cleanup work for me so
instead of 8 tabs I need to manually
open our own run script instead of all
these sip cleanup steps I have to do
which include get pushes I just run
script and it just does it so you can
speed up everything immensely and
eventually you're gonna run into a tool
with anything you do in computer science
not just web dev anything where
someone's gonna say something like this
I got a tool for that it's in the repo
just go grab it and if you don't know
what that means they might as well be
speaking some weird foreign language
that like makes no sense cuz they
literally are they are speaking the
language of bash which is we'll talk
about later this beautiful common
language that we all share even though
no one's quite as fluent in and it is
anyone else thinks they are we'll get to
that
and the real power here is that we know
that fundamentally that advanced
developers can take these things called
scripts and literally do amazing things
with it if in the end the speaker notes
for these slides if you have full access
to as links to all this stuff
this is telnet blinking like tile that
blinking like that and Al you can watch
all the Star Wars and ASCII
this is just bash people you can do
anything with it but that's why that's
why is because you can do things faster
you can automate all the things and if
you can animate one thing you can
automate literally anything so if I can
automate Chrome opening eight tabs or
Firefox opening eight tabs I can
automate calling the third-party tool to
do a visual regression test there's no
difference batch doesn't care what the
file does it just is doing the exact
same thing but what what did I just say
bash is doing something so what are we
talking about here that's why I came in
this room we were talking about the
blowing in shell this is the official
logo for bash
that's in the repo it's beautiful so why
is it born again shell because there was
a guy named Steven born and he worked
for a company called Bell Labs and they
wrote this thing called Unix and there's
Berkeley UNIX and there was Bell Labs
UNIX and there was early day UNIX and he
realized that there's this fundamental
problem that they had to solve and what
he's trying to solve was inside of this
beautiful file system that his UNIX how
do we move things around and how do we
read those things to know what to do
with them that's literally what shell is
it's a shell access he's not the first
person to write a shell it wasn't the
last we'll talk about why this was
actually super valuable but that's good
there later so what does bash actually
do for those of you who in the room that
have ever looked at the Wikipedia
article like I did you'll see this
I love this definition and I think it's
way too long at the same time tech
commands cause actions that is a
fundamental thing you do with Bosch now
for those of you who don't use Bosch
does that sound fundamentally scary you
can type a command and it will do a
thing anybody all right no hands went up
and I don't if you're just shy if you
are that's fine but is this scary a
telegraph a little bit because of
electricity I think those wires by the
way those Steve persia's actual
grandfather is Telegraph machine that
human telegraphy and but you have to
learn how to take yes you learn after
you have to learn how to type something
so it's a little intimidating that you
have to know how to type on it but the
fundamental idea of a telegraph is very
simple I'm gonna send a signal from here
to there that fundamental concept in and
of itself isn't shown too scary that's
what I'm doing right now I'm sending a
message from here to you broadcasting it
mildly with my voice this is just doing
electronically from point A to point B
guess what that is all the terminal does
it points in the message or point A to
point B I guess what that's actually all
Alexa does if you look at Alexa's actual
documentation this is my favorite I dug
through a bunch of their Docs it's my
favorite like one that actually comes up
quickly on Google again the links in the
in the speaker notes what Alexa
basically does this is this is super
simplified version but it uses natural
language processing to write down a text
message of what you said so I say hey
Alexa what's the weather it's gonna
write that down and it's gonna send it
off to a third-party service somewhere
else in space lambda whatever send it
back and that's just service makes
another text message to send back and
Alexa just read you that text message
that's all X's is a fancy text messaging
machine that hooked up to cool back-end
services they can do a lot of really
cool stuff and then Alexa itself can
also do interesting things bass
text message they can see what the cards
and other interesting things he can do
but that's it we're communicating with
our machines Bosch is a way for you to
write little short messages directly to
your operating system all it really does
with those messages is move files around
and in UNIX all files are folder all
folders or files so even there it's just
moving files around but it's movie files
folders
who here is a contaminated by moving a
file to a folder like no like that with
a GUI we never would be that's a silly
question obviously on the surface that's
really all bash and its heart is doing
is saying I want this file to move over
here or I want to read that file and
figure out what the heck to do with it
we'll get to what those headers mean and
why headers are important a little bit
later we'll talk scripting but that's
all really doing then we're gonna move
it around and then read the file figure
out what the heck to do with it it's
ubiquitous so I use this computer
because it's like well it computes for
you it does the thing that the file says
to do but even windows got on board with
this with the Linux Windows 10 developer
edition with a Linux subsystem because
they're like yeah you're right this is
the most ubiquitous system that ever
gotten written in the history of the
world and if you can use it in one place
you can use it everywhere on every
machine you ever touch the entire rest
of your life thanks to - or ball
but if not just machines that you're
actively logging into as assistant men
and typing on who here uses a build
system of any sort all right who here
doesn't really know what those things
are and it's fine if you don't awesome
in the dumbest simplest terms I can put
it into not dumb in the simplest terms I
put it into which for me is like yeah
sorry it is a bash script running on a
machine you don't own that is pretty
much all circle CIS there's
configuration for it sure there's knobs
and whistles and bells but how do you
make a script run on one of these though
you give it a script to run and then put
a little things around it to say oh I
may even authenticate as me and you can
cut you can get into this github repo
and you can have access to push to here
fundamentally it's just bash with again
wow knobs and whistles around it but if
you understand what those files are and
how to read them then human readable
versions of them then you're doing the
same thing bash can do you can do it
bash can do it and you can automate it
that gets me very excited overall so
from here on out is a tutorial on the
basics of bash and again if you are bash
user everyday let's skip slide 106 and
just start reading and I guarantee you
will probably get something very
important out of that for the rest of
your life everyone else though again if
you're brand new to this know that you
can do these things if you're on a
wonder Mac or Linux machine just open it
up it's the terminal it's beautiful
there's a billion different kind of
terminals I will say bash it was one of
the solutions I forgot to say why it's
called bash cuz we talked about the born
again she'll start about that so Steven
born Ruth the shell for Bell Labs 1988 a
guy named Richard Stallman was working
with his team and said you know what
shells a really good idea we should
rewrite this and make it open source
so they wrote a new open source one and
said what should we call it well the
born again shell bash that's why I've
been bash is literally on every machine
you'll probably ever touch somewhere on
that machine it literally comes from the
heart of open source from the new
movement we have the right to tear this
thing apart and rebuild in our whatever
purpose we want to to look at the code
to manipulate it that lab said we
couldn't they just wanted us to use it
we got to extend this guy's work and it
was written by people like us by
open-source nerds I was just at nerd
summit that joke played better there
there's something up in Amherst
but bash is everywhere so just open up a
bash terminal if you're on Windows
you're gonna have to either install the
Linux subsystem or get bash just
download kit and you get a beautiful
bash client there is it full-featured no
does it work yeah can you do everything
with it yeah you're running the issues
around composer actually but we'll get
there so how the rest of this entire
deck is laid out are these four general
ideas that I'm gonna walk through and
then there's a bunch of best practices
and then I'm gonna tell you a little bit
at the end of how you can do this very
very safely without any fear of messing
up anything on your computer at all and
just how to have fun with it
because once you embrace it it's
actually super fun to make your machine
do anything you want
now if you have no idea what this is
intimidating as heck this is like
literally a terrifying screen if you
know what this is this is a beautiful
display of the access rights who owns my
code like a lot of metadata around it
and it's just a beautiful view of the
world but again if you don't know what
this is it is intimidating as heck so
let's start from the very very beginning
the first thing you see on here at the
top or at the bottom is well where you
type at on most machines it is just
default configured to tell you in this
order computer name current directory
user and then you get the dollar sign
you type after the dollar sign so a lot
of scripts you look up in your life will
start with a dollar sign don't copy the
dollar sign they'll mess things up that
tilde is a shortcut it just says that's
your home directory so and you look at
your file system it just shows you where
home is for you it's probably your name
this for me standard commands so again
we're talking about moving around a UNIX
file system so one of the first commands
anybody ever learns is PWD present
working directory I've kind of rewritten
what Manuel told me as if I was talking
to alexa because again that's all i'm
doing i'm sending short messages to my
computer so hey bash jo around that's
all PWD does hey bash what's in this
folder tell us like show me what's in
here you know I meant show me everything
in this folder and then we get to these
wonderful things that's good
dot by itself is a hidden directory
which means present directory so you can
actually invoke tools to say do this in
the directory you're in without having
to type out where directory are in you
can just say hey I'm referencing myself
I have to explain recursion before I
could explain that but
that's all that is two dots means the
level up dot file name means hide it
from me so if I say show me everything
here
great show me everything here there it
is
hidden folders are really nice because
they're like get you don't really want
to see your get folder all the time but
it's really important it's there so you
need to check on it time time who likes
reading manuals awesome I want everyone
to love manuals manuals work on planes
if you're ever like I don't have
anything to read on this plane I got
fifteen minutes to kill tech manual our
type man and any command any command in
the world and probably it's already in
there well written even manual itself
you can man man that's what I did to Bob
and tells you like very plainly Riz so
up here I did an LS a saying hey show me
everything and this is where most people
start getting a little lost
honestly like okay how do I remember
these flags what does these flags even
do there's a zillion variations of this
command it feels like there's a zillion
there's not there's like 40 or something
how do I find them all oh yeah it will
literally tell you just man LS and it
will tell you what every possible flag
is and in your spare time again render
airplanes like your Wi-Fi goes out on
you well time learner else does click in
I've crawled through a lot of manuals
it's actually really fun after a while
yeah we'll get to that we'll actually
get to that good point good point good
point we haven't got to that so far all
we're doing is reading all we're doing
is saying hey tell me where I am tell me
what's in here
tell me everything in here and then code
tell me what the manual says for this
command that was actually do stuff hey I
want to move around moving in a
different directory moving in one level
up one I just recently learned is a CD -
we'll get to that later on but it's
actually super cool but now we're just
moving around again we're not affecting
anything we're just jumping around to
where we're looking now we start doing
stuff hey let's make a directory make
directory make a new folder put a rest
copy something put it from here and
there move it moves actually super
powerful because move just doesn't say
move it from here to here you can move
something from where it is to where it
is with a new name so you can rename a
lot of things very very fast just by
moving them all again there's a thousand
flags to this you can do very very
specific things you can rename entire
sets of directories with one flag it's
pretty cool you can remove things and
this is where all those horror stories
you've ever heard in your life came from
not from this command this is eventually
pretty safe command you'll remove the
thing at a time and you can't remove
entire directories so if you're running
RM on a file you're gonna remove that
file just know that if you're on this
which a lot of things you'll see online
will tell you is RM minus RF this is
literally the only thing I think you
should be wary and scared of and the
entire talk is this this command forget
this folder and you're shouting this by
the way because that's the bf means
force R means recursive everything below
here too so if you change to your root
directory and ran this you're done
you're you've just erased your machine
you probably get it back somehow the
backup time machine but you have just
moved all your files don't run this
unless you specifically know what you're
doing if someone's told you to run it if
you're working with other people wait
for someone to tell you to do this or
you do it but this is the only real
danger this is the big red flag because
you're removing things you can add
things all day and move them around and
copy them and make your X reason no
one's really
because he moved to directory so move it
back just moved it that's all you did
but don't don't force things they feel
like what did I just do
history is there for you in fact how I
made these slides as I were in a history
and look back over two week period in my
life and in an analysis which is also in
the speaker notes from Becca and how
this deck works of how I use bash like
just from a two-week snapshot of like
this is are the commands I actually run
in my day of daily life clearing the
screen I use constantly so much that a
alias did I'll get to that in a second
that's what C is down there that means
clear so short credit it open
this is fun open things you can interact
with the whole rest your machine from
from bash like I could I could I could
jump to my spotlight view and type in
Firefox or get in FF and be right back
in Firefox and I can throw other things
the end of this like let's admit HTTP
[Music]
can't work
and I misspelled it but that's the live
demo well they're not here sitting tight
anyway the point is it does it um so you
can start experimenting with like can I
open this app to the state probably you
can if there's a way you can manipulate
it manually to get to her through the
GUI there's probably a way to open it on
that state is it that useful I use it
every day of my life so I think so but
that's the basics these are the basics
things Bosch does if you have mastered
these like eight things nine things
Wow you're on a really good path the
nine things it's not that hard to
remember
and especially sensors things you
already are doing anyway with the GUI
there's no new concepts of any of this
stuff RM minus RF maybe but that's like
move to trash and delete the trash
folder itself like don't do that
applications and tools again this comes
out of the new world the new world is
all about sharing your tools let's make
tools together to make everything better
for ourselves and some of these are
built-in grep who use grep on the
regular oh yeah for the rest you don't
learn it and once you learn in grep it's
the best search tool that ever got made
by humans it sounds amazing now it only
works on files they can see but you can
easily run a grep the the term and again
there are a zillion ways to use this
there I actually have a I run grep are
and I don't remember all the flag but
there's like five flags and it tells me
exactly the view I want with a count
included but I don't remember those five
things out of time ahead but we'll get
to why I don't remember those things a
little bit later curl one of those
useful tools on earth just pull it
across the internet and display it but
don't just curl and display everything
that's kind of madness curl mines
capital I I use literally on every
website I touch to see if the headers
are right and to see if the varnish is
working on Pantheon sites that's how you
test furnish to see the age of varnish
it's just in the header it just tells
you and it's super fast I need a clue
here for that eventually you'll hit need
to edit a file on the system that's why
we built them our VI or whatever you
pronounce it this actually if you man VI
on a Mac it will tell you it's them I
don't know why I didn't know if that's
an error or what but that's what it says
and I get I get it if you've never
touched VI before it is intimidating
because this is literally how you go
through it I don't stir it escape to go
to command mode
come on WQ to write quitter just queued
yeah so it's like a bunch of hotkeys to
learn but it's worth learning I am here
to tell you is save me a numeral amount
of hours since I started trying to use
it because I don't have to go to another
tool I just like all right I want edit
this thing VI that could that thing jump
to exactly where I want to go because I
remember the hotkeys of how to jump
around and edit it save it I am back to
my terminal back to whatever I was doing
it's super super powerful
there's also Nano if you have no idea
what VI is and you don't want to learn a
bunch of hotkeys nano is just well it
works it just works it's just there it's
another editor literally that's why it's
called now and there are thousands maybe
millions of other command the tools you
can add like if you're a it looks
terrible doesn't brew brew is awesome I
well if anybody tells me about a new
tool the first thing I do is brew
install that tool name and see if it
works sometimes it does and then I just
have a new tool that's awesome
well then other that have to go to the
github I got to figure out how to stall
it and blah blah blah blah blah Linux
it's apt again are not active act mapped
install I guess you should update that
to great in this late at night
brew install you just tell it to install
the package and it will things I've
installed but I think you're super
useful is calculator calc calc is an
amazingly powerful calculator that's I
think easier to use than figuring out
how to type the buttons because who has
like who has a keypad anymore with the
numeric keypad yeah so a few people sure
but this is my entire office a MacBook
Air I'm not joking everything I do I do
on this machine I thought it my home
machine that's true get who you just get
for everything good everybody should use
get for everything get is the best we've
ever figured out version control and for
all humanity especially for sharing I
firmly believe that not one probably
everyone
DuckDuckGo has a command-line interface
which is just amazing so our C mid camp
and this is useful for like okay that's
kind of great that I can hit one and
then like open the mid camp site sure
that's this useful but where I use this
all the time is a get you base previous
probably rollin I get a terrific traffic
I don't know how a cherry picker works
all the time so oh yeah I'm still
looking for documentation really fast in
fact a lot of get documentation
DuckDuckGo we'll just put as the first
thing it sees but all right
I was nerd not about tools I like at
this point I'm a speed up what it's not
links no she's not links not links but
the duct it goes off my standard so it's
standardized in my browser and in my
terminal drush I don't think I have to
say much about rush if you used rush and
you're not tapping into the rest of what
bash can do you are missing out oh man
don't be CLI same same exact comment but
for WordPress users Composer it's not a
require or it's not an option anymore
this is something you can just need to
know and again if you are like using
composer
without understanding bash it's
confusing the terrifying
once you understand oh I'm just reading
a file and pulling things off a shelf
based on what's in that file
that's not scary at all I mean that's a
really simplified version with closure
is but that's basically what composer is
I'm gonna read a file and pull things
off a shelf based on what's in that file
and that shelf just happens to be the
internet for any of those to the
composer drudge you typically composer
help brush help yeah it gives you all
the commands
that's an awesome point this stuff was
all written by us B hat same thing for
behavioral driven testing backstop for
pixel to pixel differences they were all
written by people who embrace the
open-source ethos and they use tools
that literally taught them how to use
the tool from within the tool
the manual was there so they wrote a
manual and helped Docs within the tool
so excellent point man and it's not just
what I showed there are thousands maybe
millions more github is literally built
off the back of this github for all's
bells and whistles and wonderfulness is
an online implementation of a shareable
git repo that's what it's heart is and
what's the point of a git repo to share
and collaborate with code all of these
tools are somewhere on github somewhere
all right but that's a lot of typing
that's an awful lot of typing and that's
where Eli's has come in Alice's work out
of this idea that I can set up a profile
for myself as a user
so these globally true things and if I
type out the full address of open
applications /firefox a PP it will open
up Firefox for me or I can just type FF
and it will do the same thing because I
can write an alias for myself I can also
tell bash where stuff is located like
I've installed a new tool great bash
does not know what's there I set a path
for it and it sure does
so aliases aliases can do a lot of cool
things but it's basically when I type
does do this instead it can be a very
short string it can be a very very very
very very very long string there's
literally no limit how long your bash
aliases can be I've seen ridiculous ones
that take up full pages but they do
amazing things yeah does it score it got
well you would have both cover our type
of us with aliases yeah exactly exactly
I type SL probably about CL so I a
latest CL to see which is clear
I get Porsche origin/master I hate
tagging that haul-out GP om every time
it works and now I have to type o like
we W e that's how I check the weather
that just gets me that element to
underground across river so I can just
type in where I am and it tells me where
I am
paths I'm not gonna go into paths but
this is just again tell bash where that
tool is so when you say open it do that
thing
but aliases actually is a very short
section hey Isis enter the other world
of like well what's the real real power
here because sure this is great these
are all shortcuts basically everything
I've shown you can get you to doing the
problem of the aliases to some extent is
like when you try to use someone else's
computer unicameral is it there's the
actual command there's that problem and
that's simply what I'm talking about
bash and not seashell are one of the
other amazing shells in the world
because this is just an implementation
of an idea there are a lot of other
open-source implementations of this idea
that rarely happens but it is amazing
when it happens like LS should anyway la
should always be La oh that's that's my
point umm I'm not gonna talk about this
but this is how you invoke it if you're
doing since a tutorial later on your own
that'll be useful but now we get into
like the real power and I said earlier
like we're gonna talk about why bash
took off and why shell won and why we
use and what we think of as a shell
isn't sea shell c shell still exists the
k shell doesn't it still exists but we
don't use it the christian there are a
thousand other shells that people have
written but none of them took off even
born himself said sea shell is a more
elegant solution except for if i want to
script things because what he did is he
figured out the problem i forget in the
turn off stop my head the problem of i
want to feed output from one command as
the input of another command typing yeah
what you said piping piping if you got
the piping problem and it's impairing to
the way he wrote shell and why we wrote
bash that way to a show so that's
getting a little advanced but there's a
this is a shell script and its simplest
terms what am i pointing to things I got
got screenshots for this we started with
well there's a hashtag which means
there's a comment I'm gonna ignore this
thing except for the very first line on
the very first line I got his out order
again I'm sorry I keep trying to improve
the order of this and I keep messing it
up on myself the very first line says
hashtag bang also known as shebang I
don't think that's where we get the
whole shebang but that's literally
what's called shebang everything after
this shebang is gonna tell you how to
run this program bash and if it says Ben
bash it knows okay I'm gonna run this as
a bash cuz that's where bash is stored
it's been bashing okay I got that I got
I know what I'm doing that if it's just
a single hashtag by itself
I'm gonna ignore it after that so when I
said this is bashas magic comment no
it's not that's what that joke is and
for those of you who didn't get that
when you walked in you're just gonna
name a file Sh
doesn't matter what's in it just as long
as it starts with that uh chin again the
shebang at the top it's gonna know what
to do with it as long as you give the
permission to do that and this is where
a lot of people like start getting lost
like oh man she my it's hard and it is
the first time you encounter changed my
change access mode change access control
lists change file modes that's what it's
changed power modes
it's confusing it's like what on earth
am i doing there are like a billion ways
I could do this for those of you who are
brand-new there's no like I'm never in a
basket before and I don't know where to
start with this literally if you were on
strim on 775 and the name of your
scripts it just works
that says I owner and maker of this
thing have full edit access and I can do
anything those file ID there and well
choose everything else they can see this
file could read it this is a very safe
way to run files if you don't know what
you're doing this is pretty safe mode
standard safe mode there are safer ways
to do it you never want to pit like all
zeros you kind of lose access to that
file altogether seven seven seven says
anyone can rewrite this file and that's
dangerous as heck too but again this is
getting in the weeds if you're going
through this by yourself this gets gets
interesting we're starting around time
and I wanted to get to some Q&A then we
run this stuff it's really easy just dot
slash name the file and his runs
you can also create your own user Ben so
that tilde slash Ben start stuffing your
own commands in there that will work
globally so when I type them as through
this type listless lists
then I fix this I hope I fixed it
thank you you know what I'm like don't
stop you can also kill out anything
about control Z and you'll jump out of
it I'm gonna do this list this is
another app I wrote a little thing I
wrote what listless does is it goes and
looks at my live website and make sure
that I'm up to date and make sure that
my auto updater ran and it did so I'm up
to date I didn't have to do anything no
updates present WordPress yeah it's a
WordPress in my blog you can or thank
you ignore that but that's that's all it
is it's like that little file called
this list I don't need the SH in there
anymore because it's written been folder
knows what to do with it again don't
need to absorb all that today just know
that's possible so what can you do with
scripts everything basically again let's
go back to what we just were talking
about bash move files around to read
files it can open things
so Bosch go over to all of these
websites actually we grew up this is not
us trying to run earlier with listless
list however II wrote this I think it is
a bug in it right now
but it's something just doesn't in the
comments have comments the experience
got this list of sites that I maintain
and then run through one or timing do
the tech same thing I just showed give
me a list of all the plugins and themes
to make sure they're all updated and
that all it's as administrator I don't
want to spend any of my time going in
and clicking buttons but I do need a way
to very quickly see if it worked
so once a week I do this on Friday
afternoon just say hey whistles list
okay we're up to date good I don't do
anything and that's my entire update
process for all of my website rest
websites open all these no no it's
checks is your yeah but that is but for
my point of view that is my update
process week to week
like I don't worry about it I know the
Machine did it because the output the
test result will all I had to look at so
that was my update process look at the
test result opens websites and Firefox
trivial sure but this is literally how
we run the weekly demo on Wednesdays at
things you want to see the weekly demo
here it is this is just open source well
again the links are down in the bottom
uh website on Pantheon
I built the tool for you'd build as many
as you want to build for off of a CSV
cuz I had to do eating sites in a day
once for a class and this does all the
handoff as well to organizations and
individual users and some pretty complex
stuff that going around clicking the
dashboard each site will taking about
four and a half minutes to do it by
myself going through the dashboard at
time did this script run takes two and a
half minutes per site but I like to run
the script once and it does that times
as many sites as I have in CSV post
content and test it with B hat backstop
before I push it production a little
weird
I'll MIT so when I write my blog posts
are random all in markdown storm and
github and I tell my machine hey go grab
them from github
go throw them up on a dubs environment
may
sure that everything worked with b-hat
because I make tons of typos obviously
and if that all worked pushed to test
and then let's go make sure pixel to
pixel it's the same things and my config
break anywhere in that cycle and if that
all work let's go ahead and push it
alive I do that for content every time
and that's for my blog
like I have no readers I don't care but
this was fun to build
and also this saves me hours of my life
because I don't want typos on my blogs I
the only user of my blog that I care
about is me in the future so I can go
back and say where did it go sing
karaoke last year when I was in town
where did I eat last time I was here
what sessions were cool
hey I heard about this idea in a session
but I don't remember oh I don't remember
who said it or exactly how they phrased
it I know I'll jump to the directory
that I store all of these files and
locally and grep them for keywords and
see what comes up and I can search all
of my notes like that every time without
thinking about it
ultimately I want to update sites and
visual regression testing to make sure
they didn't break it maybe throw in some
white house tests or some B hat tests or
selenium or throw a test name out there
sometimes I want to do that
automatically every single time there's
an update available the scripts really
available for panthéon you're more
welcome to tear it apart and do anything
you want with it and it will do all of
these amazing things all right we're
getting to the homestretch here last 15
minutes 10 minutes one of the coolest
things about bash is that this is a
universal language everyone here
probably knows a little bash they're
probably people that don't but for I
really came in this room like I know a
little bash you might not have got
anything out of so far I asked this
question literally on February 2nd and
was overwhelmed with responses like 30
people immediately Gaiman replies turned
out
Bailey's already talked about um you
didn't the up key to do the last thing
he just did
yeah I hate typing so here's everything
I've just ran all day I guess I was in
that folder for a long time testing this
little script to funds from game already
and autocomplete so so clear as multiple
things clearing it with a better one
something really long-term insurance I
love that sound I really do but it will
autocomplete for you if it something
like very long string
I don't remember I'm at right now very
my WD I'm just in the home directory
um you know us change directory Calla
yeah Donna type was K clear change
directory k and then tab and it
auto-completed for me you have to take
whole things trollee control a oh this
saves me so much time because you'd like
take forever long you want to like oh I
could get back to the beginning line
control a I'm back to the beginning they
can change it although on well I want to
get the eggs trollee and if you know
Emacs you probably spell need this
lesson because that's how he networks
worst man search not gonna explain that
today you'll find out what irony or if
you don't know it that will change your
life
bastards Astrix the wild-card character
this is how that guy supposedly deleted
everything on his servers the RM minus
RF asterisks from a root directory and
it says everything turns out was a scam
but you shouldn't ever do that um but at
the same time I'm gonna do this live
script
[Music]
so change directory to my desktop Shh
desktop and LS oh man I got tongue
screenshot so I'm gonna RM minus RF s
screen and then huh and uh Ellis and I
got no screenshots yeah not me
screenshots IR use them for something
that's why I named it to something
useful or I don't need anymore that's
the power of it
tap pipe arrow keys pipe is how you pipe
something from one to the other so I
could do an LS like I did there I could
do an LS input master clear LS and pipe
it out to a file called a dear list dot
txt and now on my desktop there is
something called its cat
dear list there's I mean that's a
trivial example but instead of copy
pasting I just said hey put it directly
there it's like one extra step I can cut
out over process because I can just say
just put it there but I can also say do
this and that or run this and then put
the output from that in here there's a
zillion ways to think about this stuff
but type stuff's all helpful if you're
like I would like to a really awesome
bash profile that saves me a lot of pain
in trouble but I don't write it myself
guess what there's a lot of examples
isn't my favorite one that anyone's
pointed out if you even have a bash
profile right now they're like I could
use some updates on that go dig out
ideas my favorite one that anyone told
me and I had never heard of this before
CD - which is basically last channel
button it's the last thing you did so if
I am clear change directory to something
like
to receive private I can't I can't I
can't this anyway it's private
oh that's why this man come yeah there
we go slash gross so I'm at my scripts
folder oh I can see the - that's cool I
can get up there but I can also come
right back to there so I can start
jumping around directories with last
channel without having to type it saves
me let's not receive me like a paragraph
we're at the type in the last month and
then there's this this applied 106 that
I can't mention it for advanced people I
ask people inside a Pantheon like hey
what's the super advanced pro tips I
should know that I could share with
people they're like yeah Bosch strict
mode and I said best strict mode what's
that and then I went looked it up and if
you are new don't do this because this
will very common things that you're
learning when you learn Bosch won't work
with us this is the strictest mode this
will fail at any conceivable fail point
but you want that if your script is
running the kubernetes cluster that
keeps up with house and run websites
this is literally forced thing you can't
have a script inside of Pantheon that
doesn't have this at the top there's
also other things but I'll talk about
those resources but ultimately this
stuff's everywhere once you learn the
basics of bash you can drop into any
machine in the world and learn bat and
like just go for it don't be afraid of
it it's just it's there and literally
for everything else in the world
just search just search there's probably
somebody's written a fully detailed
step-by-step tutorial for anything you
could conceivably want to do with bash
there exist on the internet just ask the
internet I didn't reach the skin I use
the same gift when I teach bat get but
it's same principle I want to learn how
to do this thing through the command
line oh just tell me how to do it
there's I was talking about with the it
just tells you the docks up front
but here's the fun part of course this
all sounds overwhelming there's probably
a lot of applications for your work but
honestly the command-line is fun
people have been thrown out of
universities for wasting all of their
time all night on command-line games
that true stories like go look up
history Berkeley it's amazing
the game that they were playing called
zerk there's other names for it there's
other games like it there's a lot other
games like it the first computer games
ever played in my entire life for
text-based games
hack
you can command line Nutella hack if
it's up and running this is the other
thing with tell hack it's on a weird
port and it is uh not always great but
you can just go there from your from
your browser tab it's a lack tell ah
yeah so here it is if you do this
through the browser like here this is
not your machine there is nothing to
blow up here you can do any command you
can dream up you could try to RM RF
right here I wouldn't work it's not
built it's not built for that but I got
to say it's work okay and now I'm
playing the game called Zurich and
that's figure out what I'm doing and if
you like me missed or remember that game
I'm dating myself there yeah yeah I want
to quit yes yes
and again if you mess up it will just
tell you what you're doing wrong I'm
just gonna force to quit second close
there we go because I'm not on my
terminal cuz I always used the green
screen on the terminal anyway it's a
really fun thing and you can just run
through these commands and be like wow I
didn't know my computer to give you that
I know my computer do that I know my
computer could do that
tell hack is fun as heck you can plays
org which is a really fun game for free
you'll want Prime's they'll print prime
for ever you want to write type things
and very large awesome blocky characters
in the command line it's called piglet
it's awesome you want cow say here it
came from Star Wars like that will play
the Star Wars that I was talking about
earlier and thousands of other articles
three pillars of good bash so I said
bash strictmode
those are the other two things that we
use internally Pantheon shelf the Shelf
style guide Google shell style guide and
shell check which not going to get into
today if you're an advanced user just go
dig into those and it will literally
change the way your bash scripts look
and feel I don't use them for my
personal examples so if you look at the
batch examples they're not there but
again if you're learning this stuff it
actually gets in your way a little bit
and that's really all I had to say and I
took me like an hour to say it so
there's a partner suppose clap along
with these guys again I'm Dwayne I
didn't update this slide apparently 2k
the right feedback something's gonna
release this live scribble do live sure
about that everybody if I thought I'd
updated that and that's it
so for the rest of it I got Q&A but man
there's no way I'm an expert at bash
it's it's I'm not I know what I know and
I know it's shared if to do that right
there so instead of a Q&A where you're
asking me a bunch of questions I'm happy
to answer I'm trying too happy to try to
answer let's turn this into a
conversation where if anybody has any
bash tips that they want to share I know
somebody's gotta ditch in one like
woohoo you forgot this one or you didn't
say that that's let's get him out there
Doug gray see it first okay Jeremy what
here it is
command K okay that's clear for me
that's clear for you
yes he enters for me so command K clear
screen
beautiful beautifully to save everybody
on alias
bono he was next yeah it's another shell
sure okay so this is basically an
implementation of bash with all of like
the power features figured out and
turned on already and if you're an
advanced user you're probably gonna like
this better if you're not a power user
terminal the way I'm showing it here
Bash is vanilla it's everywhere if you
know bash inside now yeah this is
probably a good choice if you don't know
bash inside now learn bash first that's
my solid advice on that because you're
never gonna drop in to a random Linux
server that hasn't been updated in five
years and finds ish there's not
guaranteed a good control gain control a
alt arrows let you skip words so what
you say oh oh there you go we're
learning together all the tips we got
double bang freebies commands so let's
run a command real quick so I actually
ruined something oh you know what it yes
[Laughter]
no actually no it on a Mac it doesn't I
know you have to go to the oh you're
right there we go it's controller a +
ctrl K does exactly that I did not know
that I've literally learned that right
now in front of you we're looking at the
and change directory up to
and then say bang bang that's what
oh no it's bang bang for me I think it's
a bang oh because where I'm at is up to
levels yeah you're absolutely right
Stevie - eating no I don't dot no I
don't I don't have that alias what else
we got okay you have a whole bunch of
knowledge in this room obviously and not
all of its me
right we need to say overwrite another
command with like make your own rep yeah
did say yes say you did an eight is this
rep and there's a thing that Congress oh
yeah
that is a built-in mechanism because
grep can't be set as an alias cuz grep
already exists in the dictionary bash
has its own dictionary of like what
things mean and grep is one of those
special words like you can't like calc
if you have Towe consolidate calc means
let's try it yeah when you source it
it'll tell you the line number of your
passion
- underscore profile so I have an alias
for a bachelor sport profile is open my
bash profile tomorrow I keep he made a
shorten it but it don't
so alias grep let's do grow that's the
trend grip equals grow yes make a grip
are you up
Group R which is a rail ASAP so let's
save it and now we're PWD did you ever
get watch just ask yourself where we are
source - love that sound
so I switched it up no dangerous I
would've said something
Wow no okay it's a grep are did that so
I thought that that was reserved
namespace the answer is no it will not
save you from yourself so be careful
your aliases then I just learned that
real time I am there I honestly thought
because I can an alias calc if you if
you do that and then just on the new
erase it from your profile or something
then it will like every time you open a
new session and evaluates your profile
so if you do that Tennyson we do we
just get rid of that mind then open it
yeah
don't worry babe you're never going to
check this constantly okay I use this
you put something in there all the
system's full writing something nothing
to install and you may not realize it
before you buy all that way you can just
come back yeah apparently you can't
overwrite that I honestly was taken me
and Doug both learned something right
now so be careful the thing is this is
completely optimal this stuff is
completely optional completely
completely optional and the only reason
you'll probably ever make one of these
isn't because someone told you to make
one is because you got tired of typing
out like where's grabar if they do you
do
fifteen ah thank you thank you yeah
grep - capital R I am I got tired of
typing that and I need don't even
remember exactly what it does it just
like the output of that better than
regular girl recursive case insensitive
in the line number yep that's it that's
it
sensitive a new iesson City that Zelda
you you can bash install Zelda game
which is actually really fun I got tired
of typing Python so tech PI but these
are things like you'll you'll this will
be your experience with bash and you'll
probably never make one of these until
you are early using the other command
anyway so like that that's probably why
we've never encountered it is if I need
grew up native I just used grew up like
I don't need grep are I in unless I want
to run grow are so this prompts as
anybody done anything magical with the
problems and how is there oh yeah here
it is and there is a zillion things you
can do with it but it's PS 1 equals okay
and you can actually have a ps2 as well
so instead like a pen to it like let's
say you want to pen what branch you're
in
um yeah that's entirely possible
it's um but I don't remember how to do
that off top my head but it's possible
but you can yeah if there's a path for
it there's probably a way to do this the
source you know what I got an alias um
it's gonna be pretty kitty sounds like
eh you might even have that already
built into it or something I hate that
the set up though yeah that's not
reading I think it's safe I feel like
I've some servers that I used to go into
if it had a branch with a traditional up
there all right well I don't know I'm
talking about in that one only ps2 one
anyway but yeah that's what you do it's
you can rename your ps1 ps1 but you just
look again this is one of those millions
and things there's a thousand things you
can do with it
someone's written a brilliant tutorial
it's just out on the Internet yeah just
surgeon yeah but it's possible
and in some ways I could use the
parameters in other ways I could change
directory because it was doing it in a
different environment whenever
the only way I was able to do it was
ready to function yeah it seems worth
sup I thank you for that actually I
didn't talk about functions you'll run
in sometimes you're like I want to do an
alias but it's really complex you can
write scripts inside of your aliases
called functions I just personally have
the opinion if I'm gonna do that I'm
gonna go ahead and make a whole script
out of that because it's easier to for
me to track its the functions are good
I'm not saying they're not it's a
personal preference thing but we're out
of time thank you very much for your way
over