No video

Bash Scripting 6 -- 'If' and Testing Explained

Conditionals and Testing in Bash -- Bash Scripting Basics for Linux
Wondering how to use logic in Bash scripts? How to use if/else in a bash program? This video will explain the basics.
Portable but painful ([)
Bash, ksh, zsh -- less portable ([[) -- but soo nice
Full Bash Scripting Basics Playlist: • Bash Scripting
Great Bash Scripting Resources:
mywiki.wooledge...
tiswww.case.edu...
Step-by-step project-based Linux course for beginners: www.udemy.com/...
Free Linux Sysadmin Course Playlist: • The Linux Basics Cours...
DigitalOcean referral link: m.do.co/c/0380...
Patreon: / tutorialinux
Official Site & e-mail list: tutorialinux.com/
Twitter: / tutorialinux
Facebook: / tutorialinux
Podcast: kernelpanicpodc...

Пікірлер: 40

  • @whiffmania
    @whiffmania3 ай бұрын

    man i love you so much youre such a great teacher i spent like 10 hours learning bash but couldnt understand it but i understood everything you taught and it was very easy to digest and process. thats a lot

  • @Xxracerx
    @Xxracerx8 жыл бұрын

    I went through the entire playlist in one and half day, practicing along on the side. I am not sure how confident i am at this moment but i have learned a lot. Thank you so much. Subscribed and looking forward to other tutorial videos. P.S - can you make more vids on networking and network troubleshooting.

  • @danielcohenemail

    @danielcohenemail

    4 жыл бұрын

    comments on video halfway point tlkin bout ifnished whole series, more den likely he means is planning on.,.. cuz lemme tell ya i tried to finish this in 4 days and very hard

  • @Mikelamont2

    @Mikelamont2

    3 жыл бұрын

    @@danielcohenemail That post was 4 years ago though, at which point there were fewer videos in the series

  • @ronaldlicaj6912
    @ronaldlicaj6912 Жыл бұрын

    Well, I started kind of late with the terminal but I would like to thank you for the content you provide here . Your explanation is exceptional. Thank you so much. God bless.

  • @Daily_life_Memories
    @Daily_life_Memories4 жыл бұрын

    I got some error while copied and ran your script of first example , i.e. comparing args number. then I realized that in the video $ was missing while calling the variable "NUM_REQUIRED_ARGS" in if condition - happy to to the troubleshooting .yay ! thanks for the nice videos :-)

  • @djosephsss
    @djosephsss6 жыл бұрын

    This is great! I am learning a lot and automating a lot of the things I have done manually for years

  • @mjebijma
    @mjebijma2 жыл бұрын

    As always, another great video! Maybe somewhat outside the scope of the video, but I missed the use of exit codes to break out of a statement under certain conditions, especially with longer (nested) conditions. This would really make it complete, but this “exit code topic” is already worth a video itself. Again, your videos are always of a distinctively higher level. Always very complete and well argued and explained. Thanks for that!

  • @tutoriaLinux

    @tutoriaLinux

    2 жыл бұрын

    Hey this is a great callout, thank you! And I really do appreciate the kind words

  • @lotuslantern1149
    @lotuslantern11498 жыл бұрын

    Very nice! I am waiting for the next lesson! Thanks, man!

  • @redhook34
    @redhook346 жыл бұрын

    Thanks these lessons were extremely helpful.

  • @piaoingrou
    @piaoingrou5 жыл бұрын

    Good job!.This helps me a lot. But I have some questions. In the line [ "$NAME" = "Dave" ] ,I can't understand why there need " " for the $NAME. So I also tried [ $NAME = "Dave" ] Both give me the same output. So I think maybe the " " for the variable is not necessary?

  • @JosephSchlimmer

    @JosephSchlimmer

    5 жыл бұрын

    Did you run the script with an argument? If it's displaying the output without an argument specified on the command line, then that means the syntax is broken, the script is ignoring the actual test and is just skipping to your output line and running it. Quotes around the variable are required in order to compare it to "Dave" as a string.

  • @Alexbl100
    @Alexbl1003 жыл бұрын

    Hey, I've realized the syntax in this tutorial is a bit outdated but it's nothing that's beyond a simple google search.

  • @dawid_dahl
    @dawid_dahl2 жыл бұрын

    Thanks a lot!

  • @badwolf8112
    @badwolf81124 жыл бұрын

    is there a difference between echoing the text result of a command with backticks compared to with parens?

  • @dal-qi3gv
    @dal-qi3gv3 жыл бұрын

    could you explain the difference between $(var_name) and ${var_name}? Thank you

  • @andreiepure6009
    @andreiepure60098 жыл бұрын

    I punched in the code that checks the number of arguments and it looks like it will print "Call this script with ./{./test.sh}

  • @kennynelcon56
    @kennynelcon565 жыл бұрын

    I keep getting syntax error after using ";" then I changed to ":" Next I got; unexpected end of file

  • @kennynelcon56

    @kennynelcon56

    5 жыл бұрын

    I solved it, God Bless Stack flow I removed the ":" and also gave space for [ $NAME="Dave" ] and, used exit $? for end of code then is in a new line . if [ $NAME="Dave" ] then echo "Dave" fi exit $? God bless Stack flow I use ubuntu

  • @babaanirudh
    @babaanirudh6 жыл бұрын

    Don't we require a $ before NUM_REQUIRED_ARGS in line 9 to access it?

  • @diegowang9597

    @diegowang9597

    2 жыл бұрын

    I have same confusion

  • @kyng386
    @kyng3868 жыл бұрын

    Do you plan to continue this series?

  • @tutoriaLinux

    @tutoriaLinux

    7 жыл бұрын

    Not in the next few months, but I'd like to re-film/expand it soon -- hopefully before next year.

  • @cafelashowerezweb
    @cafelashowerezweb4 жыл бұрын

    I am struggling to understand the idea of portability... What is it in a nutshell?

  • @NoEgg4u

    @NoEgg4u

    4 жыл бұрын

    If your script runs with zero issues on your Linux box, that does not mean that it will run issue-free on some other Linux distro. This is more likely to happen if you use features that your more modern, up-to-date box has, and then you copy your script to a different, older distro. So if there is a chance that you might ever need to copy your script to other boxes (i.e., you want your script to be portable, to be used elsewhere), then avoid using coding that might be problematic for older distros.

  • @AngriestEwok
    @AngriestEwok3 жыл бұрын

    It's been a while. Is it still a good idea to go with the old [] syntax rather than the new [[ ]]?

  • @tutoriaLinux

    @tutoriaLinux

    3 жыл бұрын

    Doubles are preferred now for test, I think! They were even when I made this video but I had been working with some legacy code when I made it, haha.

  • @VaheVan
    @VaheVan7 жыл бұрын

    Can you please provide source code for this video?

  • @researches_technical_stuff7392

    @researches_technical_stuff7392

    6 жыл бұрын

    Very difficult to work with this video on first run through due to hidden code

  • @HGCSPAVANP
    @HGCSPAVANP6 ай бұрын

    I don't know why but this feels like it should be illegal. I worked with more than 5 language c cpp java js python etc still. even PHP has some what ok ish syntax but this is hard to swallow for me. the syntax just feels odd, why cant they adopt more standard C like syntax.

  • @AlDumbrava
    @AlDumbrava7 жыл бұрын

    You didn't really cover $(ls nonexistentfile). I get that you're somehow executing ls but previously you said that we should use backticks for executing other commands inside the script. What exactly is happening here?

  • @k.osiyuk

    @k.osiyuk

    6 жыл бұрын

    You can use backticks ``, but $() is just more convenient to execute commands.

  • @Seattlefan77

    @Seattlefan77

    5 жыл бұрын

    no biggy, probably just a clear method `` wouldve drove me crazy

  • @garretmkiii
    @garretmkiii4 жыл бұрын

    And that, kids, is how you program your VCR.

  • @tutoriaLinux

    @tutoriaLinux

    4 жыл бұрын

    I wish that were true, I'd have had more luck programming my VCR :*(

  • @researches_technical_stuff7392
    @researches_technical_stuff73926 жыл бұрын

    Very difficult to work with this video on first run through due to hidden code . Lots of "unexpected end of file" messages because the end of the .sh script isn't shown to the viewer until very late in the video. This is not your best work, at all.

  • @alexfernandez9290

    @alexfernandez9290

    6 жыл бұрын

    like your name says ... you need to research more

  • @researches_technical_stuff7392

    @researches_technical_stuff7392

    6 жыл бұрын

    I don't see how any amount of research is going to clean up the presentation concern that I expressed. Perhaps English is not your first language. Can you be more clear?

  • @EzequielLFriscia

    @EzequielLFriscia

    5 жыл бұрын

    OMG... Hes explaining all step by step and you complain? Futhermore, what you are saying its nonsense.