Get sequence of numbers in bash without using seq [duplicate]












0
















This question already has an answer here:




  • How do I iterate over a range of numbers defined by variables in Bash?

    18 answers




I want to loop over a sequence of numbers in a BASH script, but the bound values are not constants. I know this syntax:



for year in {2000..2010}; do
echo ${year}
done


But the values of 2000 and 2010 are changing in my case, so what I am doing right now is this:



for year in `seq ${yeari} ${yeare}`; do
echo ${year}
done


Is there a bash-native way to do the same, without using seq?










share|improve this question















marked as duplicate by Inian bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 8:51


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    0
















    This question already has an answer here:




    • How do I iterate over a range of numbers defined by variables in Bash?

      18 answers




    I want to loop over a sequence of numbers in a BASH script, but the bound values are not constants. I know this syntax:



    for year in {2000..2010}; do
    echo ${year}
    done


    But the values of 2000 and 2010 are changing in my case, so what I am doing right now is this:



    for year in `seq ${yeari} ${yeare}`; do
    echo ${year}
    done


    Is there a bash-native way to do the same, without using seq?










    share|improve this question















    marked as duplicate by Inian bash
    Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 23 '18 at 8:51


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      0












      0








      0









      This question already has an answer here:




      • How do I iterate over a range of numbers defined by variables in Bash?

        18 answers




      I want to loop over a sequence of numbers in a BASH script, but the bound values are not constants. I know this syntax:



      for year in {2000..2010}; do
      echo ${year}
      done


      But the values of 2000 and 2010 are changing in my case, so what I am doing right now is this:



      for year in `seq ${yeari} ${yeare}`; do
      echo ${year}
      done


      Is there a bash-native way to do the same, without using seq?










      share|improve this question

















      This question already has an answer here:




      • How do I iterate over a range of numbers defined by variables in Bash?

        18 answers




      I want to loop over a sequence of numbers in a BASH script, but the bound values are not constants. I know this syntax:



      for year in {2000..2010}; do
      echo ${year}
      done


      But the values of 2000 and 2010 are changing in my case, so what I am doing right now is this:



      for year in `seq ${yeari} ${yeare}`; do
      echo ${year}
      done


      Is there a bash-native way to do the same, without using seq?





      This question already has an answer here:




      • How do I iterate over a range of numbers defined by variables in Bash?

        18 answers








      bash seq






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 8:54









      Micha Wiedenmann

      10.5k1364106




      10.5k1364106










      asked Nov 23 '18 at 8:47









      KostasKostas

      232




      232




      marked as duplicate by Inian bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 23 '18 at 8:51


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Inian bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 23 '18 at 8:51


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          0














          Have a look at man bash:




           for (( expr1 ; expr2 ; expr3 )) ; do list ; done
          First, the arithmetic expression expr1 is evaluated according to
          the rules described below under ARITHMETIC EVALUATION. The
          arithmetic expression expr2 is then evaluated repeatedly until
          it evaluates to zero. Each time expr2 evaluates to a non-zero
          value, list is executed and the arithmetic expression expr3 is
          evaluated. If any expression is omitted, it behaves as if it
          evaluates to 1. The return value is the exit status of the last
          command in list that is executed, or false if any of the expres-
          sions is invalid.



          for ((i=yeari; i<yeare; i++))
          do
          echo $i
          done


          You might possibly also be interested in 'Arithmetic Expansion' ($((expression))) of which you can find more in the man page.






          share|improve this answer






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Have a look at man bash:




             for (( expr1 ; expr2 ; expr3 )) ; do list ; done
            First, the arithmetic expression expr1 is evaluated according to
            the rules described below under ARITHMETIC EVALUATION. The
            arithmetic expression expr2 is then evaluated repeatedly until
            it evaluates to zero. Each time expr2 evaluates to a non-zero
            value, list is executed and the arithmetic expression expr3 is
            evaluated. If any expression is omitted, it behaves as if it
            evaluates to 1. The return value is the exit status of the last
            command in list that is executed, or false if any of the expres-
            sions is invalid.



            for ((i=yeari; i<yeare; i++))
            do
            echo $i
            done


            You might possibly also be interested in 'Arithmetic Expansion' ($((expression))) of which you can find more in the man page.






            share|improve this answer




























              0














              Have a look at man bash:




               for (( expr1 ; expr2 ; expr3 )) ; do list ; done
              First, the arithmetic expression expr1 is evaluated according to
              the rules described below under ARITHMETIC EVALUATION. The
              arithmetic expression expr2 is then evaluated repeatedly until
              it evaluates to zero. Each time expr2 evaluates to a non-zero
              value, list is executed and the arithmetic expression expr3 is
              evaluated. If any expression is omitted, it behaves as if it
              evaluates to 1. The return value is the exit status of the last
              command in list that is executed, or false if any of the expres-
              sions is invalid.



              for ((i=yeari; i<yeare; i++))
              do
              echo $i
              done


              You might possibly also be interested in 'Arithmetic Expansion' ($((expression))) of which you can find more in the man page.






              share|improve this answer


























                0












                0








                0







                Have a look at man bash:




                 for (( expr1 ; expr2 ; expr3 )) ; do list ; done
                First, the arithmetic expression expr1 is evaluated according to
                the rules described below under ARITHMETIC EVALUATION. The
                arithmetic expression expr2 is then evaluated repeatedly until
                it evaluates to zero. Each time expr2 evaluates to a non-zero
                value, list is executed and the arithmetic expression expr3 is
                evaluated. If any expression is omitted, it behaves as if it
                evaluates to 1. The return value is the exit status of the last
                command in list that is executed, or false if any of the expres-
                sions is invalid.



                for ((i=yeari; i<yeare; i++))
                do
                echo $i
                done


                You might possibly also be interested in 'Arithmetic Expansion' ($((expression))) of which you can find more in the man page.






                share|improve this answer













                Have a look at man bash:




                 for (( expr1 ; expr2 ; expr3 )) ; do list ; done
                First, the arithmetic expression expr1 is evaluated according to
                the rules described below under ARITHMETIC EVALUATION. The
                arithmetic expression expr2 is then evaluated repeatedly until
                it evaluates to zero. Each time expr2 evaluates to a non-zero
                value, list is executed and the arithmetic expression expr3 is
                evaluated. If any expression is omitted, it behaves as if it
                evaluates to 1. The return value is the exit status of the last
                command in list that is executed, or false if any of the expres-
                sions is invalid.



                for ((i=yeari; i<yeare; i++))
                do
                echo $i
                done


                You might possibly also be interested in 'Arithmetic Expansion' ($((expression))) of which you can find more in the man page.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 23 '18 at 8:51









                Micha WiedenmannMicha Wiedenmann

                10.5k1364106




                10.5k1364106

















                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    Origin of the phrase “under your belt”?