Score:10

How to get the output of two cat commands parallel to each other

in flag

If I run cat file1.txt, I have:

linux mint
ubuntu
cent-os
fedora
debian
kali linux
arch linux
kubuntu
open suse
deepin
parrot os

Then cat file2.txt gives:

linux mint
cent-os
fedora
kali linux
arch linux
kubuntu
open
deepin
parrot
ubuntu
debian

But what if I want to make output like this?

file1.txt                      file2.txt

linux mint                     linux mint
ubuntu                         cent-os
cent-os                        fedora
fedora                         kali linux
debian                         arch linux
kali linux                     kubuntu
arch linux                     open
kubuntu                        deepin
open suse                      parrot
deepin                         ubuntu
parrot os                      debian
ar flag
If you want to compare lines in 2 files may be you should look at the `diff` command.
Score:21
mw flag

What you need is paste commad which paste rows in files side by side:

paste file1.txt file2.txt

This outputs exactly what you wanted.

For more options check man paste.

Hannu avatar
ca flag
Additional info: `diff -y file1.txt file2.txt` may also be useful, displaying the differences between similar files, side by side.
Score:6
jp flag

pr will do what you want when used like so:

pr -mt file1.txt file2.txt
  • -m will print all files in parallel.
  • -t will omit page headers and trailers.

Example output:

linux mint              linux mint
ubuntu                  cent-os
cent-os                 fedora
fedora                  kali linux
debian                  arch linux
kali linux              kubuntu
arch linux              open
kubuntu                 deepin
open suse               parrot
deepin                  ubuntu
parrot os               debian
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.