Bash Scripting for Beginners: Complete Guide to Getting Started - While Loops (Part 7)

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 55

  • @faanross
    @faanross 2 роки тому +38

    Can't properly express how grateful I am for this series. Would love if you ever felt inclined to do a more advanced + longer course on networking, server management, and security, would GLADLY pay for that.

  • @Fallyoou
    @Fallyoou Рік тому +8

    One of the best channels here on UA-cam , i'll give you that.

  • @LinXnerd
    @LinXnerd Рік тому +1

    I thought that Jay was awesome when I started watching this bash series. Now I KNOW that Jay is awesome! I'm thrilled to be learning here and am inspired with many new programming ideas. Thank you Jay!

  • @wendyudensi2843
    @wendyudensi2843 Рік тому +5

    This series is amazing and has helped me understand many concepts easily. He is an awesome teacher. Thanks so much for creating this wonderful content

  • @whyYUbee
    @whyYUbee 7 місяців тому +2

    I love the fact of the small assignment at the end of this lesson 😊 I just made my small math quiz with while loops and it worked perfectly!

  • @sippinondroppromotions4276
    @sippinondroppromotions4276 10 місяців тому

    Please please do an intermediate/advanced tutorial for instance while loop with arithmetic functions and conditions 😢 you're such a good teacher!

  • @christopherjohns6155
    @christopherjohns6155 Рік тому

    This is a great series packed with tons of great examples.

  • @mago2007
    @mago2007 Рік тому +1

    Love the series! Love your channel! Thank you!

  • @mielushe2lheureux939
    @mielushe2lheureux939 Рік тому +2

    Great video! Thank you so much!

  • @codermomo1792
    @codermomo1792 Рік тому

    this is kind of helpful code to let you understand it more
    counter=0
    while [ $counter -le 10 ]
    do
    echo "$counter * 7 = $(( $counter * 7 ))"
    counter=$(( counter+1 ))
    done

  • @NEXUSSEC
    @NEXUSSEC 8 місяців тому +2

    Tnx captain❤😊

  • @ZaG-yo3fd
    @ZaG-yo3fd Рік тому +1

    Hi. Can you explain the subshell a bit in detail? How come you used $(date)
    What is the main reasoning and is this the only way to get the date command in this particular example?
    Thanks.

  • @FHollis-gw4cc
    @FHollis-gw4cc 2 роки тому +5

    You might have added that CTRL-C will stop a runaway loop. 🙂

    • @Abdirahmaann
      @Abdirahmaann Рік тому

      It’s choice

    • @Abdirahmaann
      @Abdirahmaann Рік тому

      But removing the file is making sense

    • @user-vt1rb1wy3u
      @user-vt1rb1wy3u Рік тому

      thank you LOL

    • @omairtech6711
      @omairtech6711 Місяць тому

      Ain't that obvious? And also that would have defeated the point of the infinite while loops.

  • @Hanesy
    @Hanesy 5 місяців тому

    Hello, how do you loop also the echo for The file no longer exists.?

  • @barkhadibraahim1023
    @barkhadibraahim1023 7 місяців тому

    great videos thanks bro

  • @peterjansen4826
    @peterjansen4826 2 роки тому +9

    myvar=$(($myvar+1))
    This part is rather unclear to me. Usually you can set a number to a variable without using a $ before the number but here you have to start with a $-sign. It is not explained why. Clearly the outer () are for the first $-sign (scope) but why do you have to put the $myvar+1 inbetween ()?

    • @nikhilrbadri5220
      @nikhilrbadri5220 Рік тому +11

      Hey, thanks for asking this, completely overlooked it. But when I went back trying to understand it, I found the reason. The $myvar+1 is an expression and per the syntax described in the manual for expr or in the earlier videos, you'd need to use expr to let bash know that you are attempting to perform an arithmetic operation. Using () around it, negates the use of expr.
      Check out the manual of expr for more details!

    • @alissonreinaldosilva1119
      @alissonreinaldosilva1119 Рік тому +3

      In other words, both work , the extra parenthesis remove the need for the expr command:
      myvar=$(expr $myvar + 1)
      myvar=$(($myvar + 1))

    • @spasha90
      @spasha90 Рік тому

      @@alissonreinaldosilva1119 This myvar=$(expr $myvar + 1) does not work, I tried

    • @DevOps691
      @DevOps691 Рік тому

      @@spasha90 it works)

    • @DevOps691
      @DevOps691 Рік тому +1

      If I understand right the myvar=$( ) - mean that the "myvar" equal use the value of the result of the variable in the ( ) and additional ( ) to just to replace typing of "expr" command, that is why $(( ))

  • @Mason-h3w6d
    @Mason-h3w6d 9 місяців тому

    Did anyone else have an issue with their results not printing out? The script ran like it was meant to but the numbers didn't appear where they were suppose to, as in there were lines of results with no numbers occupying them.

    • @neilpatrickhairless
      @neilpatrickhairless 7 місяців тому

      For me it just ran 1's without adding, script copied in verbatim

  • @frankenweeny8785
    @frankenweeny8785 Рік тому

    The videos are great but can you please to slow down more? Some of us don't understand English fast as others XD

    • @ps-ri2qk
      @ps-ri2qk Рік тому

      Under Settings icon, you can reduce the speed of the video playback if that helps

    • @hussaniislamicchannel
      @hussaniislamicchannel 9 місяців тому +1

      fr? my first language is not English and i can understand it very easily

  • @Eilay_Yosfan
    @Eilay_Yosfan 5 місяців тому

    thank you

  • @mihai6564
    @mihai6564 Рік тому

    good video

  • @subee128
    @subee128 10 місяців тому

    Thanks

  • @prasadpatel6508
    @prasadpatel6508 Рік тому

    Thank you !!

  • @KaskuserKeitt
    @KaskuserKeitt Рік тому

    cool video)

  • @sreeragsajeev2709
    @sreeragsajeev2709 Рік тому

    You are the best

  • @guilherme5094
    @guilherme5094 2 роки тому

    👍Thanks!

  • @stanislasautos3606
    @stanislasautos3606 Рік тому

    learned while loop

  • @vinamrajha1571
    @vinamrajha1571 9 місяців тому

    in if-else video, you forget to explain about else-if statements.

  • @Alpha_Sadigh
    @Alpha_Sadigh Рік тому

    ☯🙏

  • @wheezybackports6444
    @wheezybackports6444 2 роки тому

    Am I the only one who's never found a real world use for while loops? At least one where it's actually the best way to do something. Most of the time it's better to use a for loop because for loops are easier to control and are more readable.

    • @faanross
      @faanross 2 роки тому +1

      In Python you often use it to purposely induce an infinite loop and assign a break when a certain condition is met - in other words, keep doing this thing forever until x happens. This is often used for example if you prompt the user for input, but only allow them to break from the prompt if the input meets certain conditions, which you can check with for example regex. Unsure how that would work with a for loop.

    • @faanross
      @faanross 2 роки тому +1

      while True:
      # Code
      if :
      break
      # Code

    • @wheezybackports6444
      @wheezybackports6444 2 роки тому

      @@faanross yeah, but that's getting fancy with user input. I really meant while loops in bash. You almost never need them and they're hard to control. When I do user input I just have command line arguments, so the program can be scripted even if it's just something simple.

    • @GoogleAccount-ki1ww
      @GoogleAccount-ki1ww 2 роки тому

      @@wheezybackports6444
      I’m brand new to bash scripting but I was wondering if a while loop could be useful for waiting for something to finish executing/downloading/loading then once it is finished, to do something else?
      Or maybe you create a script that flags when a certain user is online and pings you whenever they go offline?

    • @wheezybackports6444
      @wheezybackports6444 2 роки тому

      @@GoogleAccount-ki1ww You can use an until loop for that too if you wanted.

  • @Ca1vema
    @Ca1vema Рік тому +1

    You're leaving important concepts unexplained while explaining simple things over and over :(
    For e.g. Why we have to use subshell and (( to override a variable?