Shrinking text in a file using bash [duplicate]

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











up vote
4
down vote

favorite













This question already has an answer here:



  • How can I wrap text at a certain column size?

    6 answers



I have text file look like this:





If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definitive operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using any major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones, TVs, automobiles, and many other devices.


i want to shrink it so it look like this



If you are a software developer in your 20s or 30s, 
you've grown up in a world dominated by Linux. It ha
s been a significant player in the data center for d
ecades, and while it's hard to find definitive opera
ting system market share reports, Linux's share of d
ata center operating systems could be as high as 70%
, with Windows variants carrying nearly all the rema
ining percentage. Developers using any major public
cloud can expect the target system will run Linux. E
vidence that Linux is everywhere has grown in recent
years when you add in Android and Linux-based embed
ded systems in smartphones, TVs, automobiles, and ma
ny other devices.


and then enlarge it so it look like this:



If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definiti
ve operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using a
ny major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones,
TVs, automobiles, and many other devices.


how can I do that, i need to include that in my script










share|improve this question









New contributor




ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Ipor Sircer, Romeo Ninov, Jeff Schaller, RalfFriedl, Thomas Dickey 3 hours ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    4
    down vote

    favorite













    This question already has an answer here:



    • How can I wrap text at a certain column size?

      6 answers



    I have text file look like this:





    If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definitive operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using any major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones, TVs, automobiles, and many other devices.


    i want to shrink it so it look like this



    If you are a software developer in your 20s or 30s, 
    you've grown up in a world dominated by Linux. It ha
    s been a significant player in the data center for d
    ecades, and while it's hard to find definitive opera
    ting system market share reports, Linux's share of d
    ata center operating systems could be as high as 70%
    , with Windows variants carrying nearly all the rema
    ining percentage. Developers using any major public
    cloud can expect the target system will run Linux. E
    vidence that Linux is everywhere has grown in recent
    years when you add in Android and Linux-based embed
    ded systems in smartphones, TVs, automobiles, and ma
    ny other devices.


    and then enlarge it so it look like this:



    If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definiti
    ve operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using a
    ny major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones,
    TVs, automobiles, and many other devices.


    how can I do that, i need to include that in my script










    share|improve this question









    New contributor




    ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.











    marked as duplicate by Ipor Sircer, Romeo Ninov, Jeff Schaller, RalfFriedl, Thomas Dickey 3 hours ago


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite












      This question already has an answer here:



      • How can I wrap text at a certain column size?

        6 answers



      I have text file look like this:





      If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definitive operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using any major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones, TVs, automobiles, and many other devices.


      i want to shrink it so it look like this



      If you are a software developer in your 20s or 30s, 
      you've grown up in a world dominated by Linux. It ha
      s been a significant player in the data center for d
      ecades, and while it's hard to find definitive opera
      ting system market share reports, Linux's share of d
      ata center operating systems could be as high as 70%
      , with Windows variants carrying nearly all the rema
      ining percentage. Developers using any major public
      cloud can expect the target system will run Linux. E
      vidence that Linux is everywhere has grown in recent
      years when you add in Android and Linux-based embed
      ded systems in smartphones, TVs, automobiles, and ma
      ny other devices.


      and then enlarge it so it look like this:



      If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definiti
      ve operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using a
      ny major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones,
      TVs, automobiles, and many other devices.


      how can I do that, i need to include that in my script










      share|improve this question









      New contributor




      ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      This question already has an answer here:



      • How can I wrap text at a certain column size?

        6 answers



      I have text file look like this:





      If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definitive operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using any major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones, TVs, automobiles, and many other devices.


      i want to shrink it so it look like this



      If you are a software developer in your 20s or 30s, 
      you've grown up in a world dominated by Linux. It ha
      s been a significant player in the data center for d
      ecades, and while it's hard to find definitive opera
      ting system market share reports, Linux's share of d
      ata center operating systems could be as high as 70%
      , with Windows variants carrying nearly all the rema
      ining percentage. Developers using any major public
      cloud can expect the target system will run Linux. E
      vidence that Linux is everywhere has grown in recent
      years when you add in Android and Linux-based embed
      ded systems in smartphones, TVs, automobiles, and ma
      ny other devices.


      and then enlarge it so it look like this:



      If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definiti
      ve operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using a
      ny major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones,
      TVs, automobiles, and many other devices.


      how can I do that, i need to include that in my script





      This question already has an answer here:



      • How can I wrap text at a certain column size?

        6 answers







      bash text-processing






      share|improve this question









      New contributor




      ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 3 hours ago









      David Foerster

      948616




      948616






      New contributor




      ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 10 hours ago









      ckameron

      283




      283




      New contributor




      ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      ckameron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      marked as duplicate by Ipor Sircer, Romeo Ninov, Jeff Schaller, RalfFriedl, Thomas Dickey 3 hours ago


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Ipor Sircer, Romeo Ninov, Jeff Schaller, RalfFriedl, Thomas Dickey 3 hours ago


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          12
          down vote



          accepted










          You can use the command fold as follows:



          fold -w 


          The flag win the command fold can control the text (shrink vs extend) depending on the number of the included columns.



          In your example:



          fold -w 52 file 


          and



          fold -w 200 file





          share|improve this answer
















          • 3




            And, if you want to actually break lines between words like normal text flow would be done, you can use fmt instead of fold...
            – twalberg
            8 hours ago

















          up vote
          3
          down vote













          You can use this command:



          sed 's/.80/&n/g' file


          Where 80 is number of characters you want to have in one line and file is file where you store your text.



          .80 - regexp which match exactly 80 characters



          &n - append n to matched text






          share|improve this answer



























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            12
            down vote



            accepted










            You can use the command fold as follows:



            fold -w 


            The flag win the command fold can control the text (shrink vs extend) depending on the number of the included columns.



            In your example:



            fold -w 52 file 


            and



            fold -w 200 file





            share|improve this answer
















            • 3




              And, if you want to actually break lines between words like normal text flow would be done, you can use fmt instead of fold...
              – twalberg
              8 hours ago














            up vote
            12
            down vote



            accepted










            You can use the command fold as follows:



            fold -w 


            The flag win the command fold can control the text (shrink vs extend) depending on the number of the included columns.



            In your example:



            fold -w 52 file 


            and



            fold -w 200 file





            share|improve this answer
















            • 3




              And, if you want to actually break lines between words like normal text flow would be done, you can use fmt instead of fold...
              – twalberg
              8 hours ago












            up vote
            12
            down vote



            accepted







            up vote
            12
            down vote



            accepted






            You can use the command fold as follows:



            fold -w 


            The flag win the command fold can control the text (shrink vs extend) depending on the number of the included columns.



            In your example:



            fold -w 52 file 


            and



            fold -w 200 file





            share|improve this answer












            You can use the command fold as follows:



            fold -w 


            The flag win the command fold can control the text (shrink vs extend) depending on the number of the included columns.



            In your example:



            fold -w 52 file 


            and



            fold -w 200 file






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 10 hours ago









            Goro

            8,11153877




            8,11153877







            • 3




              And, if you want to actually break lines between words like normal text flow would be done, you can use fmt instead of fold...
              – twalberg
              8 hours ago












            • 3




              And, if you want to actually break lines between words like normal text flow would be done, you can use fmt instead of fold...
              – twalberg
              8 hours ago







            3




            3




            And, if you want to actually break lines between words like normal text flow would be done, you can use fmt instead of fold...
            – twalberg
            8 hours ago




            And, if you want to actually break lines between words like normal text flow would be done, you can use fmt instead of fold...
            – twalberg
            8 hours ago












            up vote
            3
            down vote













            You can use this command:



            sed 's/.80/&n/g' file


            Where 80 is number of characters you want to have in one line and file is file where you store your text.



            .80 - regexp which match exactly 80 characters



            &n - append n to matched text






            share|improve this answer
























              up vote
              3
              down vote













              You can use this command:



              sed 's/.80/&n/g' file


              Where 80 is number of characters you want to have in one line and file is file where you store your text.



              .80 - regexp which match exactly 80 characters



              &n - append n to matched text






              share|improve this answer






















                up vote
                3
                down vote










                up vote
                3
                down vote









                You can use this command:



                sed 's/.80/&n/g' file


                Where 80 is number of characters you want to have in one line and file is file where you store your text.



                .80 - regexp which match exactly 80 characters



                &n - append n to matched text






                share|improve this answer












                You can use this command:



                sed 's/.80/&n/g' file


                Where 80 is number of characters you want to have in one line and file is file where you store your text.



                .80 - regexp which match exactly 80 characters



                &n - append n to matched text







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 10 hours ago









                mrc02_kr

                916319




                916319












                    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?