Shrinking text in a file using bash

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











up vote
2
down vote

favorite












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.















  • 1




    Possible duplicate of How can I wrap text at a certain column size?
    – Ipor Sircer
    41 mins ago














up vote
2
down vote

favorite












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.















  • 1




    Possible duplicate of How can I wrap text at a certain column size?
    – Ipor Sircer
    41 mins ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











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.











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







bash






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 mins ago









Rui F Ribeiro

37k1273117




37k1273117






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 49 mins ago









ckameron

183




183




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.







  • 1




    Possible duplicate of How can I wrap text at a certain column size?
    – Ipor Sircer
    41 mins ago












  • 1




    Possible duplicate of How can I wrap text at a certain column size?
    – Ipor Sircer
    41 mins ago







1




1




Possible duplicate of How can I wrap text at a certain column size?
– Ipor Sircer
41 mins ago




Possible duplicate of How can I wrap text at a certain column size?
– Ipor Sircer
41 mins ago










2 Answers
2






active

oldest

votes

















up vote
5
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



























    up vote
    1
    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




















      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
      );



      );






      ckameron is a new contributor. Be nice, and check out our Code of Conduct.









       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474261%2fshrinking-text-in-a-file-using-bash%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      5
      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
























        up vote
        5
        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






















          up vote
          5
          down vote



          accepted







          up vote
          5
          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 45 mins ago









          Goro

          7,86553472




          7,86553472






















              up vote
              1
              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
                1
                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
                  1
                  down vote










                  up vote
                  1
                  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 38 mins ago









                  mrc02_kr

                  887319




                  887319




















                      ckameron is a new contributor. Be nice, and check out our Code of Conduct.









                       

                      draft saved


                      draft discarded


















                      ckameron is a new contributor. Be nice, and check out our Code of Conduct.












                      ckameron is a new contributor. Be nice, and check out our Code of Conduct.











                      ckameron is a new contributor. Be nice, and check out our Code of Conduct.













                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474261%2fshrinking-text-in-a-file-using-bash%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      Installing NextGIS Connect into QGIS 3?

                      One-line joke