Convert certain file types within all subdirectories with dos2unix

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











up vote
0
down vote

favorite












I have thousands of files I need convert to Linux standard line ending format, i.e. using dos2unix.



The files to convert have extension either .cpp or .h



The files in question are structured in subdirectories.



I know I could find all files all with:



find ./ -follow -type f ( -iname *.cpp -o -iname *.h )


But how do I apply the command to them?



I suppose with a simple bash script with some for cycle, which I fail to write.







share|improve this question
























    up vote
    0
    down vote

    favorite












    I have thousands of files I need convert to Linux standard line ending format, i.e. using dos2unix.



    The files to convert have extension either .cpp or .h



    The files in question are structured in subdirectories.



    I know I could find all files all with:



    find ./ -follow -type f ( -iname *.cpp -o -iname *.h )


    But how do I apply the command to them?



    I suppose with a simple bash script with some for cycle, which I fail to write.







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have thousands of files I need convert to Linux standard line ending format, i.e. using dos2unix.



      The files to convert have extension either .cpp or .h



      The files in question are structured in subdirectories.



      I know I could find all files all with:



      find ./ -follow -type f ( -iname *.cpp -o -iname *.h )


      But how do I apply the command to them?



      I suppose with a simple bash script with some for cycle, which I fail to write.







      share|improve this question












      I have thousands of files I need convert to Linux standard line ending format, i.e. using dos2unix.



      The files to convert have extension either .cpp or .h



      The files in question are structured in subdirectories.



      I know I could find all files all with:



      find ./ -follow -type f ( -iname *.cpp -o -iname *.h )


      But how do I apply the command to them?



      I suppose with a simple bash script with some for cycle, which I fail to write.









      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 6 '17 at 4:38









      Vlastimil

      6,4711147120




      6,4711147120




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          just use.



          find . -type f ( -iname "*.cpp" -o -iname "*.h" ) -exec dos2unix +





          share|improve this answer




















          • + instead of ; that's a new feature to me - and one less reason to prefer xargs.
            – Jasen
            Nov 6 '17 at 9:14










          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: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f402762%2fconvert-certain-file-types-within-all-subdirectories-with-dos2unix%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          just use.



          find . -type f ( -iname "*.cpp" -o -iname "*.h" ) -exec dos2unix +





          share|improve this answer




















          • + instead of ; that's a new feature to me - and one less reason to prefer xargs.
            – Jasen
            Nov 6 '17 at 9:14














          up vote
          2
          down vote



          accepted










          just use.



          find . -type f ( -iname "*.cpp" -o -iname "*.h" ) -exec dos2unix +





          share|improve this answer




















          • + instead of ; that's a new feature to me - and one less reason to prefer xargs.
            – Jasen
            Nov 6 '17 at 9:14












          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          just use.



          find . -type f ( -iname "*.cpp" -o -iname "*.h" ) -exec dos2unix +





          share|improve this answer












          just use.



          find . -type f ( -iname "*.cpp" -o -iname "*.h" ) -exec dos2unix +






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 6 '17 at 4:44









          αғsнιη

          15.5k92563




          15.5k92563











          • + instead of ; that's a new feature to me - and one less reason to prefer xargs.
            – Jasen
            Nov 6 '17 at 9:14
















          • + instead of ; that's a new feature to me - and one less reason to prefer xargs.
            – Jasen
            Nov 6 '17 at 9:14















          + instead of ; that's a new feature to me - and one less reason to prefer xargs.
          – Jasen
          Nov 6 '17 at 9:14




          + instead of ; that's a new feature to me - and one less reason to prefer xargs.
          – Jasen
          Nov 6 '17 at 9:14

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402762%2fconvert-certain-file-types-within-all-subdirectories-with-dos2unix%23new-answer', 'question_page');

          );

          Post as a guest













































































          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