Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to print output of mutiple files side by side

Tags:

I have 4 files say:

cat test1
1 
2   
3

cat test2
4  
5  
6  

cat test3
7  
8  
9  

I need to display the content as below side by side:

1  4  7  
2  5  8  
3  5  9

I tried pr -m -t test1 test2 test3, but if if any value is large, the output is getting trim, I need to display the content according to the length of the value and should display the content side by side(column wise)

like image 678
Siva Malla Avatar asked Jul 24 '18 09:07

Siva Malla


People also ask

How do I view two files side by side in Linux?

The -m flag causes the pr command to merge the two files into two columns on a single page. Without the flag, pr will concatenate both files into two pages of output instead of displaying them in columns. Additionally, the flag -t removes the default header and newlines in the output.

How do I view multiple files in Linux?

log log files, you can view them both in one terminal by executing tail -f command . Save this answer. Usage: multitail <filename1> <filename2> . So the output will be part of file1 and part of file2 in the same terminal.

Which of the following commands will place the contents of given files side by side horizontally?

Paste command is one of the useful commands in Unix or Linux operating system. It is used to join files horizontally (parallel merging) by outputting lines consisting of lines from each file specified, separated by tab as delimiter, to the standard output.

How do I print two columns in Linux?

Printing two columnsThe pr command can print text in multiple columns. For example, -2 prints in two columns and -3 will print in three columns.


1 Answers

You can simple do it like :

cat *.txt | paste -d " " - - - | sed 's/_//g'
like image 81
Frank AK Avatar answered Sep 28 '22 17:09

Frank AK