cp: cannot stat './1_true/*': No such file or directory, when find directories and copy filesWhy do I see a difference in file count between Nautilus and find?Recursively apply the msgfmt command to all .po files in directory with find -execHow to copy files from multiple directories, adding the parent folder's name to the filename?cp command for backupHow to move files under multi-directories into same directory?Bash - Copy all .jar files to current directory from subfolders

Fast cooking bone broth

How to Taper a coil?

eDreamer's price lower than the airline itself

Cherem ceremony: candles?

What made the Tusken Raiders unable / unwilling to shoot down Luke's Landspeeder?

Where to start with a child learning chess?

How cold does it have to be to freeze a waterfall

Can a Druid Goblin use Nimble Escape while Wild Shaped into a non-agile animal form?

Do attacks that give the Grappled condition work against creatures more than 1 size larger?

ADC protection for PIC microchip

Did Roger Rabbit exist prior to the film "Who Framed Roger Rabbit?"

Large (70) stellar mass black hole disrupts astrophysics?

Why is the Marie Curie Individual Fellowship only for 'experienced researchers'?

Should a soda bottle be stored horizontally or vertically?

Can a VASIMR Plasma engine be used for vertical takeoff?

Why are these wires sticking out of battery terminal?

Is a I sus2 chord the same as a Vsus4 chord?

How true are Trump’s claims about NATO spending?

What are pros and cons around banning castling?

Where is the Windows license key on Windows 10?

Keep password in macro

Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error

What are examples of (collections of) papers which "close" a field?

Looking for a restaurant in Vienna with a name similar to "An die 2 Linsen" that served huge Schnitzel



cp: cannot stat './1_true/*': No such file or directory, when find directories and copy files


Why do I see a difference in file count between Nautilus and find?Recursively apply the msgfmt command to all .po files in directory with find -execHow to copy files from multiple directories, adding the parent folder's name to the filename?cp command for backupHow to move files under multi-directories into same directory?Bash - Copy all .jar files to current directory from subfolders






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









2


















i have many directories like this:



$ ls 
1_true 1_false 2_true 2_false 3_true 3_false ...


i want to copy files in "*_true/" to other directory.



when i run command like below



find . -name "*_true" -exec cp ""/* "../out_true" ";"


this give me error messages like this:



cp: cannot stat './1_true/*': No such file or directory
cp: cannot stat './2_true/*': No such file or directory
cp: cannot stat './3_true/*': No such file or directory
...


how to fix this error? thanks!



NOTE: my 'true' directories count is more than 100000










share|improve this question



























  • Try ... -exec echo cp ... to see what's happening

    – Tavian Barnes
    Oct 17 at 15:32

















2


















i have many directories like this:



$ ls 
1_true 1_false 2_true 2_false 3_true 3_false ...


i want to copy files in "*_true/" to other directory.



when i run command like below



find . -name "*_true" -exec cp ""/* "../out_true" ";"


this give me error messages like this:



cp: cannot stat './1_true/*': No such file or directory
cp: cannot stat './2_true/*': No such file or directory
cp: cannot stat './3_true/*': No such file or directory
...


how to fix this error? thanks!



NOTE: my 'true' directories count is more than 100000










share|improve this question



























  • Try ... -exec echo cp ... to see what's happening

    – Tavian Barnes
    Oct 17 at 15:32













2













2









2








i have many directories like this:



$ ls 
1_true 1_false 2_true 2_false 3_true 3_false ...


i want to copy files in "*_true/" to other directory.



when i run command like below



find . -name "*_true" -exec cp ""/* "../out_true" ";"


this give me error messages like this:



cp: cannot stat './1_true/*': No such file or directory
cp: cannot stat './2_true/*': No such file or directory
cp: cannot stat './3_true/*': No such file or directory
...


how to fix this error? thanks!



NOTE: my 'true' directories count is more than 100000










share|improve this question
















i have many directories like this:



$ ls 
1_true 1_false 2_true 2_false 3_true 3_false ...


i want to copy files in "*_true/" to other directory.



when i run command like below



find . -name "*_true" -exec cp ""/* "../out_true" ";"


this give me error messages like this:



cp: cannot stat './1_true/*': No such file or directory
cp: cannot stat './2_true/*': No such file or directory
cp: cannot stat './3_true/*': No such file or directory
...


how to fix this error? thanks!



NOTE: my 'true' directories count is more than 100000







bash find






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 17 at 8:19







sailfish009

















asked Oct 17 at 5:51









sailfish009sailfish009

1275 bronze badges




1275 bronze badges















  • Try ... -exec echo cp ... to see what's happening

    – Tavian Barnes
    Oct 17 at 15:32

















  • Try ... -exec echo cp ... to see what's happening

    – Tavian Barnes
    Oct 17 at 15:32
















Try ... -exec echo cp ... to see what's happening

– Tavian Barnes
Oct 17 at 15:32





Try ... -exec echo cp ... to see what's happening

– Tavian Barnes
Oct 17 at 15:32










3 Answers
3






active

oldest

votes


















2



















You can simplify it quite a bit



cp ?_true/* ../out_true/


will work as well.



This will, however, not work when you have a very large number of files.






share|improve this answer






















  • 1





    your code will work if my true directories count is less than 10. but my directories is more than 100000.

    – sailfish009
    Oct 17 at 7:00











  • What defines the maximum size for a command single argument

    – bac0n
    Oct 17 at 15:44



















1



















found answer, using xargs instead of -exec



find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' -- 





share|improve this answer
































    1





















    You can limit find to descend not more than n levels with -maxdepth. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.



    find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;


    or



    for i in *_true; do
    rsync -a "$i/" ../out_true
    done





    share|improve this answer




























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "89"
      ;
      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: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f1181540%2fcp-cannot-stat-1-true-no-such-file-or-directory-when-find-directories-a%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown


























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2



















      You can simplify it quite a bit



      cp ?_true/* ../out_true/


      will work as well.



      This will, however, not work when you have a very large number of files.






      share|improve this answer






















      • 1





        your code will work if my true directories count is less than 10. but my directories is more than 100000.

        – sailfish009
        Oct 17 at 7:00











      • What defines the maximum size for a command single argument

        – bac0n
        Oct 17 at 15:44
















      2



















      You can simplify it quite a bit



      cp ?_true/* ../out_true/


      will work as well.



      This will, however, not work when you have a very large number of files.






      share|improve this answer






















      • 1





        your code will work if my true directories count is less than 10. but my directories is more than 100000.

        – sailfish009
        Oct 17 at 7:00











      • What defines the maximum size for a command single argument

        – bac0n
        Oct 17 at 15:44














      2















      2











      2









      You can simplify it quite a bit



      cp ?_true/* ../out_true/


      will work as well.



      This will, however, not work when you have a very large number of files.






      share|improve this answer
















      You can simplify it quite a bit



      cp ?_true/* ../out_true/


      will work as well.



      This will, however, not work when you have a very large number of files.







      share|improve this answer















      share|improve this answer




      share|improve this answer








      edited Oct 17 at 7:47

























      answered Oct 17 at 6:46









      vidarlovidarlo

      14.8k6 gold badges35 silver badges61 bronze badges




      14.8k6 gold badges35 silver badges61 bronze badges










      • 1





        your code will work if my true directories count is less than 10. but my directories is more than 100000.

        – sailfish009
        Oct 17 at 7:00











      • What defines the maximum size for a command single argument

        – bac0n
        Oct 17 at 15:44













      • 1





        your code will work if my true directories count is less than 10. but my directories is more than 100000.

        – sailfish009
        Oct 17 at 7:00











      • What defines the maximum size for a command single argument

        – bac0n
        Oct 17 at 15:44








      1




      1





      your code will work if my true directories count is less than 10. but my directories is more than 100000.

      – sailfish009
      Oct 17 at 7:00





      your code will work if my true directories count is less than 10. but my directories is more than 100000.

      – sailfish009
      Oct 17 at 7:00













      What defines the maximum size for a command single argument

      – bac0n
      Oct 17 at 15:44






      What defines the maximum size for a command single argument

      – bac0n
      Oct 17 at 15:44














      1



















      found answer, using xargs instead of -exec



      find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' -- 





      share|improve this answer





























        1



















        found answer, using xargs instead of -exec



        find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' -- 





        share|improve this answer



























          1















          1











          1









          found answer, using xargs instead of -exec



          find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' -- 





          share|improve this answer














          found answer, using xargs instead of -exec



          find . -name "*_true" -print0 | xargs --null -I sh -c 'cp "$1"/* "../out_true"' -- 






          share|improve this answer













          share|improve this answer




          share|improve this answer










          answered Oct 17 at 6:21









          sailfish009sailfish009

          1275 bronze badges




          1275 bronze badges
























              1





















              You can limit find to descend not more than n levels with -maxdepth. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.



              find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;


              or



              for i in *_true; do
              rsync -a "$i/" ../out_true
              done





              share|improve this answer































                1





















                You can limit find to descend not more than n levels with -maxdepth. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.



                find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;


                or



                for i in *_true; do
                rsync -a "$i/" ../out_true
                done





                share|improve this answer





























                  1















                  1











                  1











                  You can limit find to descend not more than n levels with -maxdepth. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.



                  find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;


                  or



                  for i in *_true; do
                  rsync -a "$i/" ../out_true
                  done





                  share|improve this answer


















                  You can limit find to descend not more than n levels with -maxdepth. This will match *_true and copy the content using rsync. Trailing slash on the source directory will change the behavior of rsync and only copy the content of the directory and not the directory it self.



                  find -maxdepth 1 -type d -name '*_true' -exec rsync -a "/" ../out_true ;


                  or



                  for i in *_true; do
                  rsync -a "$i/" ../out_true
                  done






                  share|improve this answer















                  share|improve this answer




                  share|improve this answer








                  edited Oct 17 at 12:42

























                  answered Oct 17 at 8:09









                  bac0nbac0n

                  1,1151 silver badge13 bronze badges




                  1,1151 silver badge13 bronze badges































                      draft saved

                      draft discarded















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • 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%2faskubuntu.com%2fquestions%2f1181540%2fcp-cannot-stat-1-true-no-such-file-or-directory-when-find-directories-a%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

                      Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                      Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                      Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її