Sample Header Ad - 728x90

How to print multiple columns without truncating?

1 vote
1 answer
793 views
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)
Asked by Timothy Swan (141 rep)
Apr 18, 2018, 08:54 PM
Last activity: Apr 18, 2018, 09:39 PM