Today's article is a neat way to view text files...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
11,809
Reaction score
10,374
Credits
97,674
Have you ever wanted to view two text files side by side? Well, you can. If you've never done this, it's still really quite easy. You don't even need to install anything (probably). You have all the tools you need already installed.


I like being able to do this, though I also make use of the diff application quite a bit.
 


So this is how it was before Linux had desktop environments? Terminal work until you saw flashes of code on the walls every time you blinked?

I wonder how many lines of code it took to turn this into only a couple of clicks away.
 
So this is how it was before Linux had desktop environments?

Yup. People still do it to this day. That and diff are pretty potent tools for checking text files.

Hmm... I should have included a picture of the output. It's pretty handy.
 
To avoid truncation of longer lines, one can use the -J option:
Code:
[flip@flop ~]$ cat filea
the quick brown fox jumps over the lazy dog

[flip@flop ~]$ cat fileb
the quick brown dog jumps over the lazy fox


[flip@flop ~]$ pr -m -t filea fileb
the quick brown fox jumps over the  the quick brown dog jumps over the

[flip@flop ~]$ pr -m -t -J filea fileb
the quick brown fox jumps over the lazy dog     the quick brown dog jumps over the lazy fox

Alternatively, specify page width with the -W or --page-width=PAGE_WIDTH options.

This is on a debian box.
 
Alternative to side-by-side output is the paste command:
Code:
[flip@flop ~]$ paste filea fileb 
the quick brown fox jumps over the lazy dog      the quick brown dog jumps over the lazy fox
 
--page-width=PAGE_WIDTH options.

I almost mentioned this but thought it'd be too complicated for people.

Alternative to side-by-side output is the paste command:

You can also use sdiff if you want. I may actually cover that one as well, just because I can and because it's probably already installed with diff. So, folks won't need to install anything for that one either.
 
Thank you for this tip. I would have to use ordinary Debian, because my installation of MX Linux "Wildflower" doesn't have it. (scratch head)

I should add that EndeavourOS comes with Meld, which could be used to compare text files. I used to be rather ignorant about such a program, because it looks enough like an ordinary text editor.
 
because my installation of MX Linux "Wildflower" doesn't have it. (scratch head)

That's crazy. It's part of the core utilities, which means it should be installed on pretty much everything outside of really light distros for stuff like embedded Linux.

Why would MX remove it?!? I assume they added some of the core utilities, as Linux is gonna need many of those tools.
 
... because my installation of MX Linux "Wildflower" doesn't have it. (scratch head)

On MX Linux I tried again, opened the man page:

Code:
$ man pr

and it opened successfully. Huh? So what happened the other time? :rolleyes:

I'm sorry. There are things going on at home.

I wound up writing a review about MX Linux after I wrote about two other distros, but I can't find the text files in my backups. It must have gotten lost with my removing one of the installations because it refused to boot properly. :/

Again, thank you for the tips, which cause someone's knowledge of Linux to increase everyday!
 
So what happened the other time? :rolleyes:

Typo maybe? I dunno.

Again, thank you for the tips, which cause someone's knowledge of Linux to increase everyday!

I think I've learned more from this project than anyone else does. Still, it's great to give back to the community. The number of people who read the articles (usually via search engine results) is amazing.
 


Top