How to print multiple columns without truncating?

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











up vote
0
down vote

favorite












I know that pr -m -t file1 file2 will give me 2 columns like so:



file1:



a
abc
abcdefg
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz


file2:



1
123
12345678
12345678901234567890


-



$ pr -m -t file1 file2
a 1
abc 123
abcdefg 12345678
abcdefghijklmnopqrstuvwxyzabcdefghi 12345678901234567890


Above is a literal cut and paste, but here I added spaces to show how it really lines up in the terminal:



$ pr -m -t file1 file2
a 1
abc 123
abcdefg 12345678
abcdefghijklmnopqrstuvwxyzabcdefghi 12345678901234567890


For some reason, unix stack exchange doesn't make the code blocks solid.
Anyway, I don't need the line numbers to match up (but to answer the general question, you could also answer how to do that) but the main property I want is to make it so that the lines wrap instead of getting truncated. Do I have no choice but to preprocess each file to a certain width and pipe that in? If so, how would I even do that?



Update: I suppose if there was some command which restricted the width of a file and forced wrapping into new lines, I'd do: pr -m -t <(command file1) <(command file2)







share|improve this question





















  • what is your desired output?
    – glenn jackman
    Apr 18 at 21:14






  • 1




    Do you want something like paste file1 file2 or paste file1 file2 | column -t?
    – glenn jackman
    Apr 18 at 21:15






  • 1




    Or adding a -J to your pr command (to join full lines and not truncate)
    – cunninghamp3
    Apr 18 at 21:16














up vote
0
down vote

favorite












I know that pr -m -t file1 file2 will give me 2 columns like so:



file1:



a
abc
abcdefg
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz


file2:



1
123
12345678
12345678901234567890


-



$ pr -m -t file1 file2
a 1
abc 123
abcdefg 12345678
abcdefghijklmnopqrstuvwxyzabcdefghi 12345678901234567890


Above is a literal cut and paste, but here I added spaces to show how it really lines up in the terminal:



$ pr -m -t file1 file2
a 1
abc 123
abcdefg 12345678
abcdefghijklmnopqrstuvwxyzabcdefghi 12345678901234567890


For some reason, unix stack exchange doesn't make the code blocks solid.
Anyway, I don't need the line numbers to match up (but to answer the general question, you could also answer how to do that) but the main property I want is to make it so that the lines wrap instead of getting truncated. Do I have no choice but to preprocess each file to a certain width and pipe that in? If so, how would I even do that?



Update: I suppose if there was some command which restricted the width of a file and forced wrapping into new lines, I'd do: pr -m -t <(command file1) <(command file2)







share|improve this question





















  • what is your desired output?
    – glenn jackman
    Apr 18 at 21:14






  • 1




    Do you want something like paste file1 file2 or paste file1 file2 | column -t?
    – glenn jackman
    Apr 18 at 21:15






  • 1




    Or adding a -J to your pr command (to join full lines and not truncate)
    – cunninghamp3
    Apr 18 at 21:16












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I know that pr -m -t file1 file2 will give me 2 columns like so:



file1:



a
abc
abcdefg
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz


file2:



1
123
12345678
12345678901234567890


-



$ pr -m -t file1 file2
a 1
abc 123
abcdefg 12345678
abcdefghijklmnopqrstuvwxyzabcdefghi 12345678901234567890


Above is a literal cut and paste, but here I added spaces to show how it really lines up in the terminal:



$ pr -m -t file1 file2
a 1
abc 123
abcdefg 12345678
abcdefghijklmnopqrstuvwxyzabcdefghi 12345678901234567890


For some reason, unix stack exchange doesn't make the code blocks solid.
Anyway, I don't need the line numbers to match up (but to answer the general question, you could also answer how to do that) but the main property I want is to make it so that the lines wrap instead of getting truncated. Do I have no choice but to preprocess each file to a certain width and pipe that in? If so, how would I even do that?



Update: I suppose if there was some command which restricted the width of a file and forced wrapping into new lines, I'd do: pr -m -t <(command file1) <(command file2)







share|improve this question













I know that pr -m -t file1 file2 will give me 2 columns like so:



file1:



a
abc
abcdefg
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz


file2:



1
123
12345678
12345678901234567890


-



$ pr -m -t file1 file2
a 1
abc 123
abcdefg 12345678
abcdefghijklmnopqrstuvwxyzabcdefghi 12345678901234567890


Above is a literal cut and paste, but here I added spaces to show how it really lines up in the terminal:



$ pr -m -t file1 file2
a 1
abc 123
abcdefg 12345678
abcdefghijklmnopqrstuvwxyzabcdefghi 12345678901234567890


For some reason, unix stack exchange doesn't make the code blocks solid.
Anyway, I don't need the line numbers to match up (but to answer the general question, you could also answer how to do that) but the main property I want is to make it so that the lines wrap instead of getting truncated. Do I have no choice but to preprocess each file to a certain width and pipe that in? If so, how would I even do that?



Update: I suppose if there was some command which restricted the width of a file and forced wrapping into new lines, I'd do: pr -m -t <(command file1) <(command file2)









share|improve this question












share|improve this question




share|improve this question








edited Apr 18 at 21:04
























asked Apr 18 at 20:54









Timothy Swan

816




816











  • what is your desired output?
    – glenn jackman
    Apr 18 at 21:14






  • 1




    Do you want something like paste file1 file2 or paste file1 file2 | column -t?
    – glenn jackman
    Apr 18 at 21:15






  • 1




    Or adding a -J to your pr command (to join full lines and not truncate)
    – cunninghamp3
    Apr 18 at 21:16
















  • what is your desired output?
    – glenn jackman
    Apr 18 at 21:14






  • 1




    Do you want something like paste file1 file2 or paste file1 file2 | column -t?
    – glenn jackman
    Apr 18 at 21:15






  • 1




    Or adding a -J to your pr command (to join full lines and not truncate)
    – cunninghamp3
    Apr 18 at 21:16















what is your desired output?
– glenn jackman
Apr 18 at 21:14




what is your desired output?
– glenn jackman
Apr 18 at 21:14




1




1




Do you want something like paste file1 file2 or paste file1 file2 | column -t?
– glenn jackman
Apr 18 at 21:15




Do you want something like paste file1 file2 or paste file1 file2 | column -t?
– glenn jackman
Apr 18 at 21:15




1




1




Or adding a -J to your pr command (to join full lines and not truncate)
– cunninghamp3
Apr 18 at 21:16




Or adding a -J to your pr command (to join full lines and not truncate)
– cunninghamp3
Apr 18 at 21:16










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










EDIT:



Care about alignment?



If you take the perl script found here, written by Peter Stuifzand, and were to name it columnFix.perl and chmod u+x columnFix.perl (to be sure you can execute it, you can do this:



pr -J -m -t file1 file2 | /path/to/columnFix.perl



Original answer:



The versions of pr I have truncate lines by default to 72 characters, with 2 columns that cuts the first column to 35 (35 char/column * 2 columns) + 1 char/separator = 71 characters (so the second column is possibly 36 characters).



So the same command you've run but with a -J should do what you seem to be looking for (with as close to your original command as possible) if you are fine with no column alignment (this is a similar result to the paste command suggested in comments)



pr -J -m -t file1 file2



From the man page:




-J, --join-line



merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators







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



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f438597%2fhow-to-print-multiple-columns-without-truncating%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
    0
    down vote



    accepted










    EDIT:



    Care about alignment?



    If you take the perl script found here, written by Peter Stuifzand, and were to name it columnFix.perl and chmod u+x columnFix.perl (to be sure you can execute it, you can do this:



    pr -J -m -t file1 file2 | /path/to/columnFix.perl



    Original answer:



    The versions of pr I have truncate lines by default to 72 characters, with 2 columns that cuts the first column to 35 (35 char/column * 2 columns) + 1 char/separator = 71 characters (so the second column is possibly 36 characters).



    So the same command you've run but with a -J should do what you seem to be looking for (with as close to your original command as possible) if you are fine with no column alignment (this is a similar result to the paste command suggested in comments)



    pr -J -m -t file1 file2



    From the man page:




    -J, --join-line



    merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators







    share|improve this answer



























      up vote
      0
      down vote



      accepted










      EDIT:



      Care about alignment?



      If you take the perl script found here, written by Peter Stuifzand, and were to name it columnFix.perl and chmod u+x columnFix.perl (to be sure you can execute it, you can do this:



      pr -J -m -t file1 file2 | /path/to/columnFix.perl



      Original answer:



      The versions of pr I have truncate lines by default to 72 characters, with 2 columns that cuts the first column to 35 (35 char/column * 2 columns) + 1 char/separator = 71 characters (so the second column is possibly 36 characters).



      So the same command you've run but with a -J should do what you seem to be looking for (with as close to your original command as possible) if you are fine with no column alignment (this is a similar result to the paste command suggested in comments)



      pr -J -m -t file1 file2



      From the man page:




      -J, --join-line



      merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators







      share|improve this answer

























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        EDIT:



        Care about alignment?



        If you take the perl script found here, written by Peter Stuifzand, and were to name it columnFix.perl and chmod u+x columnFix.perl (to be sure you can execute it, you can do this:



        pr -J -m -t file1 file2 | /path/to/columnFix.perl



        Original answer:



        The versions of pr I have truncate lines by default to 72 characters, with 2 columns that cuts the first column to 35 (35 char/column * 2 columns) + 1 char/separator = 71 characters (so the second column is possibly 36 characters).



        So the same command you've run but with a -J should do what you seem to be looking for (with as close to your original command as possible) if you are fine with no column alignment (this is a similar result to the paste command suggested in comments)



        pr -J -m -t file1 file2



        From the man page:




        -J, --join-line



        merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators







        share|improve this answer















        EDIT:



        Care about alignment?



        If you take the perl script found here, written by Peter Stuifzand, and were to name it columnFix.perl and chmod u+x columnFix.perl (to be sure you can execute it, you can do this:



        pr -J -m -t file1 file2 | /path/to/columnFix.perl



        Original answer:



        The versions of pr I have truncate lines by default to 72 characters, with 2 columns that cuts the first column to 35 (35 char/column * 2 columns) + 1 char/separator = 71 characters (so the second column is possibly 36 characters).



        So the same command you've run but with a -J should do what you seem to be looking for (with as close to your original command as possible) if you are fine with no column alignment (this is a similar result to the paste command suggested in comments)



        pr -J -m -t file1 file2



        From the man page:




        -J, --join-line



        merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators








        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited Apr 18 at 21:39


























        answered Apr 18 at 21:24









        cunninghamp3

        473215




        473215






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f438597%2fhow-to-print-multiple-columns-without-truncating%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