Fireship · @fireship

Bash in 100 Seconds

Uploaded August 23, 2021 · Length 2:33

Bash in 100 Seconds

Summary

bash basics: command line, shell, scripting, and automation in 100 seconds.

  • bash
  • command line
  • shell scripting
  • unix
  • linux
  • terminal

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    bash a command language interpreter for

  2. 0:02

    interacting with a computer from the

  3. 0:04

    command line it's also called a shell

  4. 0:06

    because it surrounds the operating

  5. 0:08

    system kernel to hide its intricate

  6. 0:09

    details while allowing you the

  7. 0:11

    programmer to do important stuff like

  8. 0:13

    access data and write files by typing

  9. 0:16

    simple commands this was a revolutionary

  10. 0:18

    concept when it was developed in the

  11. 0:19

    early 70s back when programmers were

  12. 0:21

    still using punch cards the shell

  13. 0:23

    concept evolved over the years with the

  14. 0:25

    bourne shell being the most popular

  15. 0:26

    version that is until 1989 when the

  16. 0:28

    born-again shell or bash came about when

  17. 0:31

    you open up the terminal on a unix

  18. 0:33

    machine like mac os and most linux

  19. 0:35

    distros the default shell is usually

  20. 0:37

    bash it provides a prompt where you can

  21. 0:40

    type a command which will then be

  22. 0:41

    interpreted by the shell and executed on

  23. 0:43

    the operating system to find out if

  24. 0:45

    you're running bash type in which dollar

  25. 0:47

    sign shell from the command line it's

  26. 0:49

    like any other application that lives in

  27. 0:51

    the binaries directory but bash is also

  28. 0:53

    a programming language that allows us to

  29. 0:55

    write scripts which means anything we

  30. 0:57

    type manually into the command line can

  31. 0:58

    be automated with code when you first

  32. 1:00

    launch the shell it actually runs a

  33. 1:02

    startup script that's defined in the

  34. 1:04

    bash profile or bashrc file on your

  35. 1:07

    system this allows you to customize the

  36. 1:09

    behavior and appearance of the shell

  37. 1:10

    whenever you start a new session you can

  38. 1:12

    add your own custom bash scripts to any

  39. 1:14

    project by creating a file that ends in

  40. 1:16

    dot sh for no file extension at all the

  41. 1:19

    first line in that file should always be

  42. 1:21

    a shebang followed by the path to the

  43. 1:23

    application that should run it below

  44. 1:25

    that we can start writing commands like

  45. 1:27

    echo to print something and they'll be

  46. 1:28

    interpreted line by line to create a

  47. 1:30

    variable type a name in all caps

  48. 1:32

    followed by the equal sign then

  49. 1:34

    reference it later in the script using a

  50. 1:36

    dollar sign in front of the name now to

  51. 1:38

    execute the script simply type the file

  52. 1:40

    name into the shell that was easy but

  53. 1:42

    what if we want to pass in some

  54. 1:44

    arguments when we run the script

  55. 1:45

    positional arguments will automatically

  56. 1:47

    be assigned variable names of 1 2 3 and

  57. 1:50

    so on now in other cases you may need

  58. 1:52

    additional user input in the middle of a

  59. 1:54

    script you can create loops in bash like

  60. 1:56

    a do while loop here that will prompt

  61. 1:58

    the user to continue the script on a yes