Why won't the for loop execute for more than 4 iterations?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












In the following script, the for loop only outputs till unph4. I tried to write the value of $coils directly but doesn't work as well. I tried other iteration values to see the maximum I am getting is 9 (does the iteration number have to be a single digit?)



coil=34;

bash_command = sprintf(['for ph in all/ph[1-$coil].niin' ...
'don' ...
' base=`basename $ph`;n' ...
' dir=`dirname $ph`;n' ...
' mag=$dir/"mag"$base:2;n' ...
' unph="unph"$base:2;n' ...
' prelude -a $mag -p $ph -u $unph -n 12&n' ...
'donen' ...
'waitn' ...
'gunzip -f unph*.gzn']);

unix(bash_command);









share|improve this question









New contributor




A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    0
    down vote

    favorite












    In the following script, the for loop only outputs till unph4. I tried to write the value of $coils directly but doesn't work as well. I tried other iteration values to see the maximum I am getting is 9 (does the iteration number have to be a single digit?)



    coil=34;

    bash_command = sprintf(['for ph in all/ph[1-$coil].niin' ...
    'don' ...
    ' base=`basename $ph`;n' ...
    ' dir=`dirname $ph`;n' ...
    ' mag=$dir/"mag"$base:2;n' ...
    ' unph="unph"$base:2;n' ...
    ' prelude -a $mag -p $ph -u $unph -n 12&n' ...
    'donen' ...
    'waitn' ...
    'gunzip -f unph*.gzn']);

    unix(bash_command);









    share|improve this question









    New contributor




    A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      In the following script, the for loop only outputs till unph4. I tried to write the value of $coils directly but doesn't work as well. I tried other iteration values to see the maximum I am getting is 9 (does the iteration number have to be a single digit?)



      coil=34;

      bash_command = sprintf(['for ph in all/ph[1-$coil].niin' ...
      'don' ...
      ' base=`basename $ph`;n' ...
      ' dir=`dirname $ph`;n' ...
      ' mag=$dir/"mag"$base:2;n' ...
      ' unph="unph"$base:2;n' ...
      ' prelude -a $mag -p $ph -u $unph -n 12&n' ...
      'donen' ...
      'waitn' ...
      'gunzip -f unph*.gzn']);

      unix(bash_command);









      share|improve this question









      New contributor




      A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      In the following script, the for loop only outputs till unph4. I tried to write the value of $coils directly but doesn't work as well. I tried other iteration values to see the maximum I am getting is 9 (does the iteration number have to be a single digit?)



      coil=34;

      bash_command = sprintf(['for ph in all/ph[1-$coil].niin' ...
      'don' ...
      ' base=`basename $ph`;n' ...
      ' dir=`dirname $ph`;n' ...
      ' mag=$dir/"mag"$base:2;n' ...
      ' unph="unph"$base:2;n' ...
      ' prelude -a $mag -p $ph -u $unph -n 12&n' ...
      'donen' ...
      'waitn' ...
      'gunzip -f unph*.gzn']);

      unix(bash_command);






      bash for






      share|improve this question









      New contributor




      A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited Nov 22 at 1:24









      Stephen Harris

      23k24176




      23k24176






      New contributor




      A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Nov 22 at 0:46









      A. De

      1




      1




      New contributor




      A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      A. De is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          Because all/ph[1-34].nii matches at most 4 files: all/ph1.nii, all/ph2.nii, all/ph3.nii, and all/ph4.nii.



          In shell patterns, a construction of the form [char1-char2] matches the characters which sort between char1 and char2; so [1-34] matchs 1, 2, 3 and 4.



          You may want to change the for loop to



          for i in $(seq 1 $coil)
          do
          ph=all/ph$i.nii
          ...
          done





          share|improve this answer






















          • Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
            – A. De
            Nov 22 at 19:57











          • It is working -- that's an error message from your application prelude. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
            – AlexP
            Nov 22 at 21:30











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          A. De is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483333%2fwhy-wont-the-for-loop-execute-for-more-than-4-iterations%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote













          Because all/ph[1-34].nii matches at most 4 files: all/ph1.nii, all/ph2.nii, all/ph3.nii, and all/ph4.nii.



          In shell patterns, a construction of the form [char1-char2] matches the characters which sort between char1 and char2; so [1-34] matchs 1, 2, 3 and 4.



          You may want to change the for loop to



          for i in $(seq 1 $coil)
          do
          ph=all/ph$i.nii
          ...
          done





          share|improve this answer






















          • Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
            – A. De
            Nov 22 at 19:57











          • It is working -- that's an error message from your application prelude. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
            – AlexP
            Nov 22 at 21:30















          up vote
          2
          down vote













          Because all/ph[1-34].nii matches at most 4 files: all/ph1.nii, all/ph2.nii, all/ph3.nii, and all/ph4.nii.



          In shell patterns, a construction of the form [char1-char2] matches the characters which sort between char1 and char2; so [1-34] matchs 1, 2, 3 and 4.



          You may want to change the for loop to



          for i in $(seq 1 $coil)
          do
          ph=all/ph$i.nii
          ...
          done





          share|improve this answer






















          • Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
            – A. De
            Nov 22 at 19:57











          • It is working -- that's an error message from your application prelude. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
            – AlexP
            Nov 22 at 21:30













          up vote
          2
          down vote










          up vote
          2
          down vote









          Because all/ph[1-34].nii matches at most 4 files: all/ph1.nii, all/ph2.nii, all/ph3.nii, and all/ph4.nii.



          In shell patterns, a construction of the form [char1-char2] matches the characters which sort between char1 and char2; so [1-34] matchs 1, 2, 3 and 4.



          You may want to change the for loop to



          for i in $(seq 1 $coil)
          do
          ph=all/ph$i.nii
          ...
          done





          share|improve this answer














          Because all/ph[1-34].nii matches at most 4 files: all/ph1.nii, all/ph2.nii, all/ph3.nii, and all/ph4.nii.



          In shell patterns, a construction of the form [char1-char2] matches the characters which sort between char1 and char2; so [1-34] matchs 1, 2, 3 and 4.



          You may want to change the for loop to



          for i in $(seq 1 $coil)
          do
          ph=all/ph$i.nii
          ...
          done






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 at 11:53

























          answered Nov 22 at 0:54









          AlexP

          6,9391024




          6,9391024











          • Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
            – A. De
            Nov 22 at 19:57











          • It is working -- that's an error message from your application prelude. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
            – AlexP
            Nov 22 at 21:30

















          • Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
            – A. De
            Nov 22 at 19:57











          • It is working -- that's an error message from your application prelude. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
            – AlexP
            Nov 22 at 21:30
















          Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
          – A. De
          Nov 22 at 19:57





          Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
          – A. De
          Nov 22 at 19:57













          It is working -- that's an error message from your application prelude. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
          – AlexP
          Nov 22 at 21:30





          It is working -- that's an error message from your application prelude. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
          – AlexP
          Nov 22 at 21:30











          A. De is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          A. De is a new contributor. Be nice, and check out our Code of Conduct.












          A. De is a new contributor. Be nice, and check out our Code of Conduct.











          A. De is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483333%2fwhy-wont-the-for-loop-execute-for-more-than-4-iterations%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?