Writing your first bash script

Поделиться
HTML-код
  • Опубликовано: 21 ноя 2024

Комментарии • 94

  • @Cappsy
    @Cappsy Месяц назад +32

    Give us this day our daily bread

  • @DV-ml4fm
    @DV-ml4fm 17 дней назад +2

    You can use the select statement to create and display a menu of items to choose from.

  • @OldDogNewLinux
    @OldDogNewLinux 10 дней назад +1

    There are those who know how to streamline the code you showed, but I appreciate that you explained variables, if, case, sed, & awk in just a few lines of code in just 16 minutes. This was helpful for us noobs out here. Thank you.

    • @BreadOnPenguins
      @BreadOnPenguins  9 дней назад +1

      I appreciate that! I do think it could've been better, but the goal was just some quick and dirty code for showing examples. No problem.

    • @OldDogNewLinux
      @OldDogNewLinux 9 дней назад +1

      @@BreadOnPenguins I'm very new to bash scripting so your "quick & dirty" is very helpful to see the process, as well as the different options you presented. Keeping it simple for noobs such as myself is appreciated. Knowing there are more advanced ways of doing the same thing is cool, but I'm not quite there yet.

  • @SS-gu2tx
    @SS-gu2tx Месяц назад +22

    A technically literate and practical Linux RUclipsr. I don't think I've ever seen one. Subbed!

  • @BrokenKanuck
    @BrokenKanuck 22 дня назад +2

    sed and awk are two tools everyone should get to grips with, they're incredibly powerful. Love the vids! Keep it up! Still learning new things even after 30 years of Linux..

    • @BreadOnPenguins
      @BreadOnPenguins  22 дня назад +1

      For sure - I'll 100% be making vids on both at some point. Thanks so much :) Glad to hear.

  • @lupuionut6286
    @lupuionut6286 Месяц назад +5

    I hope you maintain interest in this channel and that it grows more. There seems to be some sort of Linux oriented market on youtube, currently. I'm a dude working in CI, where we automate stuff a lot using bash scripts. Probably this video would've helped me when I started out with it, like half an year ago.

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад +2

      I definitely intend to!
      Gotcha, it's not a hard learning curve once you've gotten started. Bash scripting is applicable in so many areas, as well.

  • @shayanakhavan6002
    @shayanakhavan6002 8 дней назад

    I’m glad I stumbled upon your video! My use of bash scripting has been lost over the years

    • @BreadOnPenguins
      @BreadOnPenguins  8 дней назад

      Thanks for stopping by! I've got several other vids going over other useful/practical scripts as well

  • @PreRenderedRealities
    @PreRenderedRealities Месяц назад +5

    These kinds of videos, where you use several different tools in combination, really show the strength of command-line proficiency. I learn something from every one of your videos! I would love to see you flex more of your sed/awk skillset because that stuff is fascinating.

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад +2

      Thanks so much - I'm glad to hear that! I'm definitely intending to make full videos for sed, awk, even grep and other tools.

  • @mauriereed3875
    @mauriereed3875 Месяц назад +4

    The case / esac combination comes from the gentleman who wrote the Bourne shell and comes from the Algol programming language which used reversed keywords to mark the end of code blocks. Glad that I discovered your channel a short time ago!

  • @JD-du3qe
    @JD-du3qe Месяц назад +3

    excellent video, actual practical example demonstrating multiple concepts, unlike some other first bash script videos I've seen. look forward to more from you! thanks

  • @saiswayamshree
    @saiswayamshree Месяц назад +3

    best concise guide. keep making more such videos

  • @SpaceCatKungFu
    @SpaceCatKungFu Месяц назад +5

    Wow, you rule! You're a great teacher; much appreciated!!

  • @marian.fratica
    @marian.fratica Месяц назад +4

    Greetings from Romania! Just discovered your channel. Very well-structured content with very clean explanations from such a young girl. :) You can easily become a teacher. :P Keep up the good work!

  • @retagif
    @retagif 26 дней назад +1

    Thank you very for this on learning bash, truly enlightening video

  • @AshesWake-sf7uw
    @AshesWake-sf7uw 29 дней назад +2

    Penguinz0 if he was really cool linux person! Love your videos

  • @notafbihoneypot8487
    @notafbihoneypot8487 Месяц назад +4

    Based bash🗿 I'm glad I'm watching this from the terminal

  • @metalmeditations2036
    @metalmeditations2036 Месяц назад +1

    SWEET! As promised. Sadly I'm too busy preparing for a professional certification exam to dive into this until week after next, but I am excited to get started.

  • @kalemolala
    @kalemolala Месяц назад +2

    the contents you makes are amazing!

  • @MocanuAndreiCristian
    @MocanuAndreiCristian Месяц назад +1

    Hey, I like your theme. Your Terminal looks great, your Desktop looks amazing. Would you mind sharing your configurations with us?

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад +1

      Thank you! I have a few videos going through how I've configured some aspects and will make more on the subject. I will eventually make a repo for dotfiles (but I'll have to clean up and organize everything neatly, first).

  • @lautaroliva18
    @lautaroliva18 Месяц назад +1

    Hey Bread, great vid! Also, where do you find your wallpapers?? Thery're great

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад

      Thank you! :)
      Everything from stock photo sites, to /wg/ threads, to looking through work from artists and photographers

  • @karshPrime
    @karshPrime 16 дней назад +1

    the fastest penguin species is the gentoo penguin, which can reach speeds of up to 36 kmph when swimming

  • @mrslacker1437
    @mrslacker1437 Месяц назад +1

    Let's gooo! THANK YOU! Keep up the good work!

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад

      No problem and thanks for watching! :) Will do

  • @aidenmiller893
    @aidenmiller893 Месяц назад +3

    Super useful content, ty

  • @null11q
    @null11q Месяц назад +2

    Luke doesn't care about noobs!
    Meanwhile, Luke with his AI girl form:

  • @vinay_dias
    @vinay_dias Месяц назад +2

    A penguins black and white colouring is called counter-shading.

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад +2

      Hey that's an interesting one, I just looked it up since I hadn't known about it before, apparently it applies to many different animals in order to camouflage. Thanks for sharing!!

  • @krisdjames
    @krisdjames Месяц назад +4

    Closing an if statement with 'fi' is not unique to Bash, it was also the convention in Bourne script, the predecessor to Bash, as well as most other Unix shells, so they just kept it. Dude who wrote Bourne came from Algol 68 where the reverse closing delimiter was originally used. So 'if/fi', 'case/esac' are unique but you close 'do' with 'done' because 'od' was already used. The others like 'while', 'for' or 'until' are called within do and don't need a terminating delimiter. So basically it's just creative arbitrary decisions of old.

  • @Brosmule
    @Brosmule Месяц назад +4

    you give off MoistCr1TiKaL vibes

  • @simon7149
    @simon7149 Месяц назад +1

    You can use cut -d'%' -f1 instead of sed. Might be a little bit faster

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад

      For sure, I was going to use cut but figured it was better to introduce people to awk and sed.

  • @VioletJewel1729
    @VioletJewel1729 Месяц назад +1

    woo woo another good video hehe ^_^

  • @AnalyticMinded
    @AnalyticMinded Месяц назад +8

    I know you are doing beginner-level tutorials for now, but I hope one day you make one about the more obscure aspects of utilities like sed, awk, xargs, grep, etc. Oh, and regex... :P

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад +5

      Yeah, those are worth going over especially for maximizing efficiency - I'll keep it in mind. :D

  • @astrx2
    @astrx2 26 дней назад +1

    Can you make a video about your vim setup ?

    • @BreadOnPenguins
      @BreadOnPenguins  26 дней назад

      Hello, sure! It's on the to-do list :)

    • @astrx2
      @astrx2 25 дней назад

      Thank you, you are the best creator !

  • @xmvziron
    @xmvziron 17 дней назад +1

    1:37 Fun fact: you don't even need to look beyond Linux to see that, NixOS doesn't have /bin/bash, so you are forced to put /usr/bin/env bash in the shebang. /bin/sh does exist though.

    • @BreadOnPenguins
      @BreadOnPenguins  16 дней назад

      Good to know! All the more reason to use a universally applicable shebang

  • @dekooks1543
    @dekooks1543 Месяц назад +2

    not sure if anybody asked before but what keyboard do you use ?

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад +2

      It's a razer blackwidow v4 atm, but I'm only using it because I got it cheaply from a friend - honestly I wouldn't recommend it since I've had several issues with switches becoming unresponsive, apparently this is a common issue with this model

  • @nikospitr
    @nikospitr 18 дней назад

    Why the double brackets in " if [[ $myvar -gt 90 ]] ??? Are they really necessary?
    Also, out of curiosity, why the case needs double ;; to separate choices?

  • @Lucaux
    @Lucaux Месяц назад +1

    any chance we will see u using wayland ??

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад

      I'll probably make a video about it at some point :)

  • @TrustJesusToday
    @TrustJesusToday Месяц назад +1

    Fun stuff.

  • @synoim
    @synoim Месяц назад +4

    You're so cool lol

  • @wilk85
    @wilk85 Месяц назад +1

    Hope you are using shell check in daily 'bashing'?

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад +1

      That's a useful too as well :)

    • @wilk85
      @wilk85 Месяц назад +1

      @@BreadOnPenguins yep, it will keep you on track with latest syntax

  • @VioletJewel1729
    @VioletJewel1729 Месяц назад +1

    double quote "$variables" (almost) always hehe. and double quote "$(captured subshells)" hehe.

  • @HaukeLaging
    @HaukeLaging 28 дней назад +1

    The shebang line does not tell the shell how to run the script, it tells the kernel how to run the script.
    It is rather strange to pipe output from awk (the much more powerful tool for text modification) to sed. The solution is to do that in awk (value=$5; sub("%","",value); print value) or in bash:
    myvar=$( ... )
    myvar="${myvar%\%}"
    But you need neither awk nor sed, you can do that in bash directly:
    df -h / | ( while read dev v2 v3 v4 percentage rest; do [[ $dev != /dev/* ]] && continue; echo "$percentage"; done )

    • @BreadOnPenguins
      @BreadOnPenguins  28 дней назад +1

      I did want to show both awk and sed in the video since those are commonly used tools that are worth introducing, even if that's not the "best" way for that particular example. Regardless, I appreciate the full explanations - thanks for commenting!

    • @OldDogNewLinux
      @OldDogNewLinux 10 дней назад

      ​@@BreadOnPenguins That's awesome that @HaukeLaging was able to condense the script down to one or two lines. Something to grasp in the future as I learn to crawl before I can run. Thank you for explaining awk & sed. I'm new to bash scripting, just a couple of months now and I'm loving the sed command. It's so powerful and yet I know only 10% of it's capability.

  • @Gigusx
    @Gigusx Месяц назад +1

    There are penguins in South America

    • @BreadOnPenguins
      @BreadOnPenguins  Месяц назад +1

      South America has some very distinctive penguins! The Humboldt penguin is a cool species, super interesting coloring

    • @Gigusx
      @Gigusx Месяц назад +1

      @@BreadOnPenguins They do have cool coloring! The beaks as well :D

  • @shawnlowery6246
    @shawnlowery6246 24 дня назад +1

    Not bash related, but you may want to consider always putting a consistent graphic or photo of a smiling Bread on your video thumbnails. This Bread video almost got overlooked on my little phone.

    • @BreadOnPenguins
      @BreadOnPenguins  24 дня назад

      Thanks for pointing that out! I'm still experimenting with what thumbnail style works best

  • @lukegallo1272
    @lukegallo1272 Месяц назад +1

    Luke Smith transitioned? I was wondering where he went... makes sense... typical linux chud

  • @samoylov1973
    @samoylov1973 16 дней назад +1

    Nice work! Keep it up! (I get it - you want to show several commands. At least you said it in comments)
    But - your code could and should be better. Why use more than you actually need for a simple task.
    #!/usr/bin/env bash
    clear
    # Prints disk info: essentials
    df -h | awk '/\/$/ {print "Used: "$3"\t Available: "$4}'
    And of course you can do more elegantly with "if then else" statements. DT compared you with Luke Smith.
    So, why not watch Luke's "Never say "If" writing a Bash script" wonderful video? 😺

    • @BreadOnPenguins
      @BreadOnPenguins  15 дней назад

      Hello, thank you for commenting!
      I have indeed seen Luke's video; if I recall, there was significant debate in the comments over concise vs elegant.
      Verbosity can be appropriate in the circumstance that others need to quickly and easily understand your code.
      Given the concept of this video, my priority was packing in as much as possible. I agree that the end result was certainly not elegant, lol
      But, especially for personal projects, I prefer concise code, and yes, I do avoid if statements! :-)

  • @CyperN077
    @CyperN077 Месяц назад +1

    I use the more portable #!/use/bin/env bash