Problem with a simple script

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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:



PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp $PATH2 ;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi


But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB.



Do I have to put anything before find? It seems that the problem is in find.










share|improve this question
























  • do you mind editing your post to format the code correctly? Simply highlight it, then press the '' button in the text box. Thanks

    – user5359531
    Jan 12 '17 at 17:55






  • 6





    $PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.

    – user5359531
    Jan 12 '17 at 18:00












  • also if you want to test this and see what I mean, simply open a new terminal and run echo $PATH.

    – user5359531
    Jan 12 '17 at 18:01






  • 1





    Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?

    – fedeemp
    Jan 12 '17 at 18:06

















2















I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:



PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp $PATH2 ;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi


But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB.



Do I have to put anything before find? It seems that the problem is in find.










share|improve this question
























  • do you mind editing your post to format the code correctly? Simply highlight it, then press the '' button in the text box. Thanks

    – user5359531
    Jan 12 '17 at 17:55






  • 6





    $PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.

    – user5359531
    Jan 12 '17 at 18:00












  • also if you want to test this and see what I mean, simply open a new terminal and run echo $PATH.

    – user5359531
    Jan 12 '17 at 18:01






  • 1





    Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?

    – fedeemp
    Jan 12 '17 at 18:06













2












2








2








I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:



PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp $PATH2 ;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi


But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB.



Do I have to put anything before find? It seems that the problem is in find.










share|improve this question
















I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:



PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp $PATH2 ;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi


But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB.



Do I have to put anything before find? It seems that the problem is in find.







scripting aix






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 18 at 2:03









Rui F Ribeiro

42.1k1484142




42.1k1484142










asked Jan 12 '17 at 17:54









fedeempfedeemp

173




173












  • do you mind editing your post to format the code correctly? Simply highlight it, then press the '' button in the text box. Thanks

    – user5359531
    Jan 12 '17 at 17:55






  • 6





    $PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.

    – user5359531
    Jan 12 '17 at 18:00












  • also if you want to test this and see what I mean, simply open a new terminal and run echo $PATH.

    – user5359531
    Jan 12 '17 at 18:01






  • 1





    Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?

    – fedeemp
    Jan 12 '17 at 18:06

















  • do you mind editing your post to format the code correctly? Simply highlight it, then press the '' button in the text box. Thanks

    – user5359531
    Jan 12 '17 at 17:55






  • 6





    $PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.

    – user5359531
    Jan 12 '17 at 18:00












  • also if you want to test this and see what I mean, simply open a new terminal and run echo $PATH.

    – user5359531
    Jan 12 '17 at 18:01






  • 1





    Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?

    – fedeemp
    Jan 12 '17 at 18:06
















do you mind editing your post to format the code correctly? Simply highlight it, then press the '' button in the text box. Thanks

– user5359531
Jan 12 '17 at 17:55





do you mind editing your post to format the code correctly? Simply highlight it, then press the '' button in the text box. Thanks

– user5359531
Jan 12 '17 at 17:55




6




6





$PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.

– user5359531
Jan 12 '17 at 18:00






$PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.

– user5359531
Jan 12 '17 at 18:00














also if you want to test this and see what I mean, simply open a new terminal and run echo $PATH.

– user5359531
Jan 12 '17 at 18:01





also if you want to test this and see what I mean, simply open a new terminal and run echo $PATH.

– user5359531
Jan 12 '17 at 18:01




1




1





Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?

– fedeemp
Jan 12 '17 at 18:06





Hey thanks. That was the problema. Thank you !! Do I have to "close" this question?

– fedeemp
Jan 12 '17 at 18:06










2 Answers
2






active

oldest

votes


















4














$PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.






share|improve this answer






























    0














    PATH happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find or cp.



    It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.



    In this case, you could use source_dir and target_dir, for example, which have the additional benefit of providing the reader with a bit of documentation.






    share|improve this answer























      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%2f336938%2fproblem-with-a-simple-script%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      $PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.






      share|improve this answer



























        4














        $PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.






        share|improve this answer

























          4












          4








          4







          $PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.






          share|improve this answer













          $PATH is a default environment variable which tells your system where to find its program binaries (like the find program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's $PATH, and now your system cannot find the find program. Try this and see if it works.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 12 '17 at 18:20









          user5359531user5359531

          21217




          21217























              0














              PATH happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find or cp.



              It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.



              In this case, you could use source_dir and target_dir, for example, which have the additional benefit of providing the reader with a bit of documentation.






              share|improve this answer



























                0














                PATH happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find or cp.



                It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.



                In this case, you could use source_dir and target_dir, for example, which have the additional benefit of providing the reader with a bit of documentation.






                share|improve this answer

























                  0












                  0








                  0







                  PATH happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find or cp.



                  It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.



                  In this case, you could use source_dir and target_dir, for example, which have the additional benefit of providing the reader with a bit of documentation.






                  share|improve this answer













                  PATH happens to be the environment variable used by the shell to locate executables. If you unset it or change it, the shell might not find commands such as find or cp.



                  It would be better if you used lowercase variable names in scripts. It is less likely that they collide with important environment variables.



                  In this case, you could use source_dir and target_dir, for example, which have the additional benefit of providing the reader with a bit of documentation.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 12 '17 at 18:17









                  KusalanandaKusalananda

                  142k18265440




                  142k18265440



























                      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%2f336938%2fproblem-with-a-simple-script%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?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay