Stories
Slash Boxes
Comments

SoylentNews is people

posted by LaminatorX on Sunday October 12 2014, @09:19AM   Printer-friendly
from the Bad-Ass-Script-Host dept.

When I first learned about Linux in the 90’s, I read that it was possible to even write your own commands to use at the command line. Later I learned about bash scripting, and it wasn’t long before I needed to learn how to loop in bash. Looping in bash is one of the fundamental building blocks of bash programming. It isn’t hard to do at all and is worth learning. The main reason to learn looping in bash is to handle doing the same thing over and over again. They’re easy to do even at the command line. Please follow along as we look a couple of basic examples, and how you can expand on them.

http://www.tidbitsfortechs.com/2014/10/looping-in-bash/

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 3, Informative) by maxwell demon on Sunday October 12 2014, @05:11PM

    by maxwell demon (1608) on Sunday October 12 2014, @05:11PM (#105099) Journal

    Given that the $() syntax is part of POSIX, I guess unless you need to target very old systems, there's no reason to use backticks.

    Note that on some very old systems, the usual shebang line may not work either, since some old systems checked for the four-byte sequence "#! /", so they would not recognize the commonly found

    #!/bin/sh

    but only

    #! /bin/sh

    --
    The Tao of math: The numbers you can count are not the real numbers.
    Starting Score:    1  point
    Moderation   +1  
       Informative=1, Total=1
    Extra 'Informative' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   3  
  • (Score: 1) by theCoder on Sunday October 12 2014, @09:02PM

    by theCoder (3583) on Sunday October 12 2014, @09:02PM (#105264)

    Good to know. I didn't realize support was so widespread and standard. I guess I was burned on some older (maybe Solaris 8?) machines, assumed it was a bash feature only, and never tried again.