Cat files in subfolders in order given by a listgrep for multiple strings in files, and then list the files in the order of sizeRead all files in folder and subfolders - progress and size/bin/cat: Argument list too longCopy subfolders containing at least n filesHow to batch rename files using loop combination in bash?append files base on a listHow to compress all files from several subfolders?How to compress all files from all subfolders if there is no `Archive.zip` in subfolder?find and sed (find and delete)Bash script to loop through folders and list files to text

English idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)

Why didn't Caesar move against Sextus Pompey immediately after Munda?

What are the advantages and disadvantages of Manhattan-Style routing?

Is this house-rule removing the increased effect of cantrips at higher character levels balanced?

German idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)

Would switching to a proportionate House require a constitutional amendment?

Why did the Apple //e make a hideous noise if you inserted the disk upside down?

Is leaving out prefixes like "rauf", "rüber", "rein" when describing movement considered a big mistake in spoken German?

Active wildlife outside the window- Good or Bad for Cat psychology?

Why will we fail creating a self sustaining off world colony?

Russian equivalents of 能骗就骗 (if you can cheat, then cheat)

Early 2000s movie about time travel, protagonist travels back to save girlfriend, then into multiple points in future

Perform mirror symmetry transformation of 3D model (in OBJ)

Cat files in subfolders in order given by a list

Is my guitar action too high or is the bridge too high?

Installed software from source, how to say yum not to install it from package?

Journal standards vs. personal standards

Checkmate in 1 on a Tangled Board

Why should I allow multiple IPs on a website for a single session?

Is it possible to alias a column based on the result of a select+where?

Grid: different background color (of row) based on values

Meaning of the word "good" in context

What is the lowest possible AC?

he and she - er und sie



Cat files in subfolders in order given by a list


grep for multiple strings in files, and then list the files in the order of sizeRead all files in folder and subfolders - progress and size/bin/cat: Argument list too longCopy subfolders containing at least n filesHow to batch rename files using loop combination in bash?append files base on a listHow to compress all files from several subfolders?How to compress all files from all subfolders if there is no `Archive.zip` in subfolder?find and sed (find and delete)Bash script to loop through folders and list files to text













2















I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file.



x/ale/ale.pest 
x/bae/bae.pest
x/galo/galo.pest


I have a list in folder y containing the order I should cat .pest files



bae
galo
ale


from my x folder I'm trying



for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list


but it's not working.










share|improve this question


























    2















    I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file.



    x/ale/ale.pest 
    x/bae/bae.pest
    x/galo/galo.pest


    I have a list in folder y containing the order I should cat .pest files



    bae
    galo
    ale


    from my x folder I'm trying



    for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list


    but it's not working.










    share|improve this question
























      2












      2








      2








      I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file.



      x/ale/ale.pest 
      x/bae/bae.pest
      x/galo/galo.pest


      I have a list in folder y containing the order I should cat .pest files



      bae
      galo
      ale


      from my x folder I'm trying



      for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list


      but it's not working.










      share|improve this question














      I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file.



      x/ale/ale.pest 
      x/bae/bae.pest
      x/galo/galo.pest


      I have a list in folder y containing the order I should cat .pest files



      bae
      galo
      ale


      from my x folder I'm trying



      for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list


      but it's not working.







      bash shell-script






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      Madza Yasodara Farias VirgensMadza Yasodara Farias Virgens

      304 bronze badges




      304 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          1














          To answer the follow-up subtly different question:




          I'm still wondering how would be if my subdirectories didnt have same names as in list though....




          Let's make some assumptions:



          • All the subdirectories of x are fair game.

          • All .pest files are fair game.

          • If you have two .pest files with the same name (but in different directories), you don't care what order those two files will be cated in.

          Then you have:



          while read -r name; do
          cat x/*/"$name.pest"
          done <y/list >concatenated.pest


          Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)






          share|improve this answer























          • Yup. It did it's thing. Thxs!

            – Madza Yasodara Farias Virgens
            7 hours ago


















          3














          You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:



          #!/bin/sh

          while read -r name; do
          cat "x/$name/$name.pest"
          done <y/list >concatenated.pest


          This would concatenate all the relevant .pest files and create a single file called concatenated.pest from these in the current directory, in the order read from y/list.



          With a bit of checking included:



          #!/bin/sh

          while read -r name; do
          pathname="x/$name/$name.pest"

          if [ ! -f "$pathname" ]; then
          printf 'Can not find %sn' "$pathname"
          echo 'Output file will be incomplete'
          exit 1
          fi >&2

          cat "$pathname"
          done <y/list >concatenated.pest





          share|improve this answer




















          • 1





            Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...

            – Madza Yasodara Farias Virgens
            7 hours ago






          • 1





            @MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual .pest file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.

            – Kusalananda
            7 hours ago












          • got it! k I'll post as a different question bc I'm also having to process some files like that. thxs

            – Madza Yasodara Farias Virgens
            7 hours ago











          • I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.

            – Wildcard
            7 hours ago













          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%2f527571%2fcat-files-in-subfolders-in-order-given-by-a-list%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









          1














          To answer the follow-up subtly different question:




          I'm still wondering how would be if my subdirectories didnt have same names as in list though....




          Let's make some assumptions:



          • All the subdirectories of x are fair game.

          • All .pest files are fair game.

          • If you have two .pest files with the same name (but in different directories), you don't care what order those two files will be cated in.

          Then you have:



          while read -r name; do
          cat x/*/"$name.pest"
          done <y/list >concatenated.pest


          Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)






          share|improve this answer























          • Yup. It did it's thing. Thxs!

            – Madza Yasodara Farias Virgens
            7 hours ago















          1














          To answer the follow-up subtly different question:




          I'm still wondering how would be if my subdirectories didnt have same names as in list though....




          Let's make some assumptions:



          • All the subdirectories of x are fair game.

          • All .pest files are fair game.

          • If you have two .pest files with the same name (but in different directories), you don't care what order those two files will be cated in.

          Then you have:



          while read -r name; do
          cat x/*/"$name.pest"
          done <y/list >concatenated.pest


          Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)






          share|improve this answer























          • Yup. It did it's thing. Thxs!

            – Madza Yasodara Farias Virgens
            7 hours ago













          1












          1








          1







          To answer the follow-up subtly different question:




          I'm still wondering how would be if my subdirectories didnt have same names as in list though....




          Let's make some assumptions:



          • All the subdirectories of x are fair game.

          • All .pest files are fair game.

          • If you have two .pest files with the same name (but in different directories), you don't care what order those two files will be cated in.

          Then you have:



          while read -r name; do
          cat x/*/"$name.pest"
          done <y/list >concatenated.pest


          Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)






          share|improve this answer













          To answer the follow-up subtly different question:




          I'm still wondering how would be if my subdirectories didnt have same names as in list though....




          Let's make some assumptions:



          • All the subdirectories of x are fair game.

          • All .pest files are fair game.

          • If you have two .pest files with the same name (but in different directories), you don't care what order those two files will be cated in.

          Then you have:



          while read -r name; do
          cat x/*/"$name.pest"
          done <y/list >concatenated.pest


          Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 7 hours ago









          WildcardWildcard

          23.8k10 gold badges68 silver badges179 bronze badges




          23.8k10 gold badges68 silver badges179 bronze badges












          • Yup. It did it's thing. Thxs!

            – Madza Yasodara Farias Virgens
            7 hours ago

















          • Yup. It did it's thing. Thxs!

            – Madza Yasodara Farias Virgens
            7 hours ago
















          Yup. It did it's thing. Thxs!

          – Madza Yasodara Farias Virgens
          7 hours ago





          Yup. It did it's thing. Thxs!

          – Madza Yasodara Farias Virgens
          7 hours ago











          3














          You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:



          #!/bin/sh

          while read -r name; do
          cat "x/$name/$name.pest"
          done <y/list >concatenated.pest


          This would concatenate all the relevant .pest files and create a single file called concatenated.pest from these in the current directory, in the order read from y/list.



          With a bit of checking included:



          #!/bin/sh

          while read -r name; do
          pathname="x/$name/$name.pest"

          if [ ! -f "$pathname" ]; then
          printf 'Can not find %sn' "$pathname"
          echo 'Output file will be incomplete'
          exit 1
          fi >&2

          cat "$pathname"
          done <y/list >concatenated.pest





          share|improve this answer




















          • 1





            Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...

            – Madza Yasodara Farias Virgens
            7 hours ago






          • 1





            @MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual .pest file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.

            – Kusalananda
            7 hours ago












          • got it! k I'll post as a different question bc I'm also having to process some files like that. thxs

            – Madza Yasodara Farias Virgens
            7 hours ago











          • I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.

            – Wildcard
            7 hours ago















          3














          You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:



          #!/bin/sh

          while read -r name; do
          cat "x/$name/$name.pest"
          done <y/list >concatenated.pest


          This would concatenate all the relevant .pest files and create a single file called concatenated.pest from these in the current directory, in the order read from y/list.



          With a bit of checking included:



          #!/bin/sh

          while read -r name; do
          pathname="x/$name/$name.pest"

          if [ ! -f "$pathname" ]; then
          printf 'Can not find %sn' "$pathname"
          echo 'Output file will be incomplete'
          exit 1
          fi >&2

          cat "$pathname"
          done <y/list >concatenated.pest





          share|improve this answer




















          • 1





            Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...

            – Madza Yasodara Farias Virgens
            7 hours ago






          • 1





            @MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual .pest file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.

            – Kusalananda
            7 hours ago












          • got it! k I'll post as a different question bc I'm also having to process some files like that. thxs

            – Madza Yasodara Farias Virgens
            7 hours ago











          • I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.

            – Wildcard
            7 hours ago













          3












          3








          3







          You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:



          #!/bin/sh

          while read -r name; do
          cat "x/$name/$name.pest"
          done <y/list >concatenated.pest


          This would concatenate all the relevant .pest files and create a single file called concatenated.pest from these in the current directory, in the order read from y/list.



          With a bit of checking included:



          #!/bin/sh

          while read -r name; do
          pathname="x/$name/$name.pest"

          if [ ! -f "$pathname" ]; then
          printf 'Can not find %sn' "$pathname"
          echo 'Output file will be incomplete'
          exit 1
          fi >&2

          cat "$pathname"
          done <y/list >concatenated.pest





          share|improve this answer















          You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:



          #!/bin/sh

          while read -r name; do
          cat "x/$name/$name.pest"
          done <y/list >concatenated.pest


          This would concatenate all the relevant .pest files and create a single file called concatenated.pest from these in the current directory, in the order read from y/list.



          With a bit of checking included:



          #!/bin/sh

          while read -r name; do
          pathname="x/$name/$name.pest"

          if [ ! -f "$pathname" ]; then
          printf 'Can not find %sn' "$pathname"
          echo 'Output file will be incomplete'
          exit 1
          fi >&2

          cat "$pathname"
          done <y/list >concatenated.pest






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 7 hours ago

























          answered 8 hours ago









          KusalanandaKusalananda

          153k18 gold badges302 silver badges483 bronze badges




          153k18 gold badges302 silver badges483 bronze badges







          • 1





            Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...

            – Madza Yasodara Farias Virgens
            7 hours ago






          • 1





            @MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual .pest file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.

            – Kusalananda
            7 hours ago












          • got it! k I'll post as a different question bc I'm also having to process some files like that. thxs

            – Madza Yasodara Farias Virgens
            7 hours ago











          • I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.

            – Wildcard
            7 hours ago












          • 1





            Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...

            – Madza Yasodara Farias Virgens
            7 hours ago






          • 1





            @MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual .pest file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.

            – Kusalananda
            7 hours ago












          • got it! k I'll post as a different question bc I'm also having to process some files like that. thxs

            – Madza Yasodara Farias Virgens
            7 hours ago











          • I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.

            – Wildcard
            7 hours ago







          1




          1





          Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...

          – Madza Yasodara Farias Virgens
          7 hours ago





          Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...

          – Madza Yasodara Farias Virgens
          7 hours ago




          1




          1





          @MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual .pest file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.

          – Kusalananda
          7 hours ago






          @MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual .pest file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.

          – Kusalananda
          7 hours ago














          got it! k I'll post as a different question bc I'm also having to process some files like that. thxs

          – Madza Yasodara Farias Virgens
          7 hours ago





          got it! k I'll post as a different question bc I'm also having to process some files like that. thxs

          – Madza Yasodara Farias Virgens
          7 hours ago













          I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.

          – Wildcard
          7 hours ago





          I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.

          – Wildcard
          7 hours ago

















          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%2f527571%2fcat-files-in-subfolders-in-order-given-by-a-list%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 : Літери Ком — Левиправивши або дописавши її