kornShell and AIX unable to create an Array Variable

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












1















LS=`ls "$SRC_PATH"/* | grep -i -v *.ignore`


I cannot use for loop as I need to check conditions with while as there are multiple conditions.



Trying to access the content using



$LS[$CNT]
CNT=`expr $CNT + 1`


I am unable to access the contents.










share|improve this question




























    1















    LS=`ls "$SRC_PATH"/* | grep -i -v *.ignore`


    I cannot use for loop as I need to check conditions with while as there are multiple conditions.



    Trying to access the content using



    $LS[$CNT]
    CNT=`expr $CNT + 1`


    I am unable to access the contents.










    share|improve this question


























      1












      1








      1


      0






      LS=`ls "$SRC_PATH"/* | grep -i -v *.ignore`


      I cannot use for loop as I need to check conditions with while as there are multiple conditions.



      Trying to access the content using



      $LS[$CNT]
      CNT=`expr $CNT + 1`


      I am unable to access the contents.










      share|improve this question
















      LS=`ls "$SRC_PATH"/* | grep -i -v *.ignore`


      I cannot use for loop as I need to check conditions with while as there are multiple conditions.



      Trying to access the content using



      $LS[$CNT]
      CNT=`expr $CNT + 1`


      I am unable to access the contents.







      aix array






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 12 at 1:08









      Rui F Ribeiro

      39.6k1479132




      39.6k1479132










      asked Jan 11 at 22:38









      Bootham DeyyamBootham Deyyam

      111




      111




















          1 Answer
          1






          active

          oldest

          votes


















          2














          We'll start with Do not parse the output of ls because it's always good to remind people of this.



          Next note that the grep probably isn't doing what you want; you likely want .ignore$ to make it skip files ending with ".ignore"



          Since we're using ksh you don't need to call expr; you can just do let CNT=CNT+1



          Now..



          To set an array in ksh you need to use set -A syntax.



          eg



          set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')


          Now $LS[0] will be the first file, etc etc.



          eg if we have



          $ ls X 
          a b c


          Then



          $ set -A LS $(ls X)
          $ echo $LS[0]
          a
          $ echo $LS[1]
          b
          $ echo $LS[2]
          c





          share|improve this answer























          • Thank you very much, this worked.

            – Bootham Deyyam
            Jan 13 at 19:33










          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',
          autoActivateHeartbeat: false,
          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494040%2fkornshell-and-aix-unable-to-create-an-array-variable%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









          2














          We'll start with Do not parse the output of ls because it's always good to remind people of this.



          Next note that the grep probably isn't doing what you want; you likely want .ignore$ to make it skip files ending with ".ignore"



          Since we're using ksh you don't need to call expr; you can just do let CNT=CNT+1



          Now..



          To set an array in ksh you need to use set -A syntax.



          eg



          set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')


          Now $LS[0] will be the first file, etc etc.



          eg if we have



          $ ls X 
          a b c


          Then



          $ set -A LS $(ls X)
          $ echo $LS[0]
          a
          $ echo $LS[1]
          b
          $ echo $LS[2]
          c





          share|improve this answer























          • Thank you very much, this worked.

            – Bootham Deyyam
            Jan 13 at 19:33















          2














          We'll start with Do not parse the output of ls because it's always good to remind people of this.



          Next note that the grep probably isn't doing what you want; you likely want .ignore$ to make it skip files ending with ".ignore"



          Since we're using ksh you don't need to call expr; you can just do let CNT=CNT+1



          Now..



          To set an array in ksh you need to use set -A syntax.



          eg



          set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')


          Now $LS[0] will be the first file, etc etc.



          eg if we have



          $ ls X 
          a b c


          Then



          $ set -A LS $(ls X)
          $ echo $LS[0]
          a
          $ echo $LS[1]
          b
          $ echo $LS[2]
          c





          share|improve this answer























          • Thank you very much, this worked.

            – Bootham Deyyam
            Jan 13 at 19:33













          2












          2








          2







          We'll start with Do not parse the output of ls because it's always good to remind people of this.



          Next note that the grep probably isn't doing what you want; you likely want .ignore$ to make it skip files ending with ".ignore"



          Since we're using ksh you don't need to call expr; you can just do let CNT=CNT+1



          Now..



          To set an array in ksh you need to use set -A syntax.



          eg



          set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')


          Now $LS[0] will be the first file, etc etc.



          eg if we have



          $ ls X 
          a b c


          Then



          $ set -A LS $(ls X)
          $ echo $LS[0]
          a
          $ echo $LS[1]
          b
          $ echo $LS[2]
          c





          share|improve this answer













          We'll start with Do not parse the output of ls because it's always good to remind people of this.



          Next note that the grep probably isn't doing what you want; you likely want .ignore$ to make it skip files ending with ".ignore"



          Since we're using ksh you don't need to call expr; you can just do let CNT=CNT+1



          Now..



          To set an array in ksh you need to use set -A syntax.



          eg



          set -A LS $(ls "$SRC_PATH"/* | grep -i -v '.ignore$')


          Now $LS[0] will be the first file, etc etc.



          eg if we have



          $ ls X 
          a b c


          Then



          $ set -A LS $(ls X)
          $ echo $LS[0]
          a
          $ echo $LS[1]
          b
          $ echo $LS[2]
          c






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 11 at 22:50









          Stephen HarrisStephen Harris

          25.5k24477




          25.5k24477












          • Thank you very much, this worked.

            – Bootham Deyyam
            Jan 13 at 19:33

















          • Thank you very much, this worked.

            – Bootham Deyyam
            Jan 13 at 19:33
















          Thank you very much, this worked.

          – Bootham Deyyam
          Jan 13 at 19:33





          Thank you very much, this worked.

          – Bootham Deyyam
          Jan 13 at 19:33

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494040%2fkornshell-and-aix-unable-to-create-an-array-variable%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?