• Uncategorized

About linux : How-to-put-tables-side-by-side-in-linux

Question Detail

I have the following code to merge several tables in Linux based on the first column. But I’m looking for codes to put several tables side by side not based on column or row. I need to have all columns and rows in each table side by side or beneath each other setting.

For example, if I have these three tables:

AA BB CC
25 40 20
13 36 19
DD EE
16 35
17 30
FF GG
15 35
17 38

So I would want this resulting table:

AA BB CC DD EE FF GG
25 40 20 16 35 15 35
13 36 19 17 30 17 38

I appreciate it if you can help me.

LANG=en_EN sort AFGEN_2018.txt | sed 's/  */\t/g' | cut -f 1 > tmp.tmp
for f in `ls results/*.txt`
do
join tmp.tmp $f > tmpf
mv tmpf tmp.tmp
done
mv tmp.tmp GSN_ALL.txt
cat GSN_ALL.txt
done

Question Answer

I found this code helpful in putting tables below each other (where *.txt is table 1, 2 and 3).

cat *.txt >Table.txt

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.