What are your favorite commands for showing differences between documents?

C

CrazedNerd

Guest
I'm personally familiar with "diff" and "comm", but the output normally tends to just confuse me, comm complains about things being un-sorted. I think it would be nice there was a totally different section for similarities and differences, and with the differences just having the document label over it. My ideal version would be like...

Code:
file1:

1. cat
2. cat
3. cat
4. dog

file2:

1. cat
2. cat
3. cat
4. cat

Let's say those are the files, if this were in this format it wouldn't confuse me:

Code:
Identical lines:

1. cat
2. cat
3. cat

Different lines:

4
_____________

file1:

4. dog

file2:

4. cat

It would result in a large output, but at least it wouldn't require any extra thinking!
 


I use 'diff' every day. If you want to not be confused, pay attention the the greater/less than signs.

< old
> changed

It's sometimes:

<
<
<
>
>
>

Meaning it is multiple lines in a row that are different. Again, the stuff with < is old. Instead of 'is less than' it means 'is older than'. Of course, this means > is 'is newer than'.

Works for me... I check the Lubuntu daily build manifest every day. Well, every day that there's a daily .iso to test. That's pretty much every day.
 
Yup! I’d second that.
Depending on what I’m doing I usually use diff, git diff, or vim -d. And occasionally, if I’m dealing with a complicated three-way merge, to resolve merge conflicts, I might use a GUI diff program like Meld, Kompare, or Diffuse.
 
You second that you use diff every day?
I was only seconding the suggestion of diff.
But now that you mention it, as a professional programmer: Yes. I use diff utilities most days.

In order to have all of my favourite Unix/Linux tools to hand (and because cmd and Powershell are basically toys compared to shells like bash and zsh), I use Cygwin on Windows at work. So diff, git diff and vim -d are part of my regular workflow on Linux (at home) and on Windows (at work).
 
I was only seconding the suggestion of diff.
But now that you mention it, as a professional programmer: Yes. I use diff utilities most days.

In order to have all of my favourite Unix/Linux tools to hand (and because cmd and Powershell are basically toys compared to shells like bash and zsh), I use Cygwin on Windows at work. So diff, git diff and vim -d are part of my regular workflow on Linux (at home) and on Windows (at work).
Can you even install tools like grep on windows? I installed a windows 7 vm so i could learn a little more about the windows cmd interpreter.
 
Can you even install tools like grep on windows? I installed a windows 7 vm so i could learn a little more about the windows cmd interpreter.
Yup. You can install Cygwin on any windows machine and can add pretty much all of the familiar unix/linux tools, including grep, sed, awk, cut, top etc. etc..
I've even managed to install X11 and dwm on windows and can also build, install and run graphical Linux applications in Cygwin/X on Windows too.

Back when KDE4 was still around, you could even install and run ALL of KDE on windows. Gnome, XFCE etc. will also run on Windows.
Sadly it can't replace the Windows desktop. But you can run X with a desktop in Windows via cygwin as if it was a separate application.

Here's a quick screenshot from the monitors on my work PC:
dwmInLinux.png


The left half of the shot is monitor 1, the right is monitor 2.
On the left of monitor 1 is my cygwin window.
On the right of monitor 1 is Chrome with this thread open.
On the right is monitor 2 running dwm via Cygwin/X.

In my cygwin window, you can see I've used cat to display the content of a script in my personal bin directory, called wm. Which I use to start dwm.
I've also ran uname -a, so you can see I'm running cygwin.
Then I ran the wm script to actually start the instance of dwm that is running in the 2nd monitor.
And at the bottom of monitor 2, you can see the Windows menu-bar.

And here's a screenshot of some applications running in dwm, on Cygwin/X on Windows:
dwmInLinux2.png

In the above screenshot, taken from monitor 2:
In dwm, the left side of the screen is the master area.
And the right hand side of the screen is known as the stack.

So the application running in the master area is gitk, a graphical application showing the git commit history of the st repository.

In the stack area, we have a terminal window at the top, which has been attached to the same tmux session that is running in the cygwin window in monitor 1 in my previous screenshot.
In it, you can see we're on the Music tab of my tmux session, which currently has cmus (terminal based music player) running, playing a song by Band Maid.
Underneath that is a window with GVim running, which I launched via dmenu - dwm's text based menu/launcher.
And at the bottom is another terminal window, which is in the source directory for suckless.org's st terminal. This is the terminal I launched gitk from.

Unfortunately, I don't have anything too fancy installed ATM.
I removed all of the things I didn't need because they were taking up too much space on my work PC's HD.
But you can clearly see dwm running in Cygwin/X on Windows. It is possible to run other Linux desktops in a similar way.
In the past, I've managed to get the XFCE, KDE4, Cinnamon, Gnome, Openbox, Enlightenment, wmii, XMonad DE's / WM's running on Windows in this way.

Again, it's not like you can replace the Windows desktop with another desktop, but it is possible to run them as if they were just another application in Windows.

The reasons I installed dwm on Windows are:
1. I really like dwm.
2. dwm has 'tags' and tags are awesome.

Basically, if I ever need to run, or connect to multiple tmux sessions at once - rather than opening several cygwin/mintty terminals and managing them from the Windows desktop, I can run dwm, open all of the terminals in different tags in dwm, starting/connecting to any tmux sessions. And then I have ALL of my terminal windows contained inside the main dwm window on the Windows desktop.
So I can more quickly and elegantly navigate between the terminal windows open in any of the tmux sessions. I can also quickly switch between the main terminals in dwm. And I can easily switch between dwm and the other applications running on the Windows desktop. It just makes things a little more fluid for me.
Whereas I don't see any practical point in running Gnome, or KDE on Windows, other than as a "Look what I can do!" type of thing. Ha ha!

But I'd be lost at work if I didn't have all of my favourite command line tools from unix/linux available to me on Windows. So Cygwin/mintty is an absolute necessity!
I can't stand cmd and powershell on windows. They just don't have enough useful tools/commands available in them. They feel more like quirky toys than fully usable terminals.
 
Last edited:
I use diff and vimdiff usually, I heard about some new diff programs written in rust but I haven't tried them yet.
 
Last edited:
Yup. You can install Cygwin on any windows machine and can add pretty much all of the familiar unix/linux tools, including grep, sed, awk, cut, top etc. etc..
Downloading/installing cygwin for windows didn't work in my VM (maybe it was the wrong link), but i did find this:


That worked...it has nano, sed, and grep by default too. It even makes those tools available to the standard cmd terminal as well.
 
Downloading/installing cygwin for windows didn't work in my VM (maybe it was the wrong link), but i did find this:


That worked...it has nano, sed, and grep by default too. It even makes those tools available to the standard cmd terminal as well.
Weird. The Cygwin website states that it should work for ALL versions of Windows from Windows 7 upwards.
Also the 3.4.x versions of Cygwin are the last versions that will support Windows 7, Windows 8, Windows Server 8 and Windows Server 2012. So from 3.5 onwards, Cygwin will only work on W10 and W11.

Maybe it's problematic to install Cygwin on a Windows VM?! IDK!! I think I've still got a Windows 10 VM on my Linux laptop - part of my virtual lab for when I'm messing with my Kali VM. I might try installing Cygwin on it later, or perhaps at the weekend, if I have time?!

All of the official links for downloading/installing Cygwin are here:
Contains everything you need to know.

Oh, and the following link tells you how to install X on cygwin:
 
Last edited:
Weird. The Cygwin website states that it should work for ALL versions of Windows from Windows 7 upwards.
Also the 3.4.x versions of Cygwin are the last versions that will support Windows 7, Windows 8, Windows Server 8 and Windows Server 2012. So from 3.5 onwards, Cygwin will only work on W10 and W11.
It gave me some sort of network error when it was trying to install, so yes i think it has something to do with the fact it's a virtual machine.
 
Cygwin is awsome! The CAD and QC groups were running out of space on the current file server. On top of that the server is over ten years old. Even worse our backup server is full and older than dirt. I found an old windows box, installed Cygwin, got it up and sharing data in day. This is NOT any kind of fix, just something to get them thru until we can get a new server. I bought two disks for storage. The main math data drive 1TB the backup drive 3.5TB

With Cygwin I was able to write some backup scripts that sync the math data to the backup drive. I did use windows scheduler to have the scripts run every 2 hours between 6am and 6pm. The new server should be on order soon. Like pretty much everyone else, we're a bit slow on work. With a little bubble gum & Bailin' wire we're limpin' along.
 
Bailin' wire

Just 'cause I'm bored, I think you'll find it's 'baling wire' from baling things together, like hay. They're bales of hay, bales of cotton, and bales of wool (among other baled items). Baling wire usually comes wrapped in tight spools.

And segue of sorts...

Baling wire is also sometimes called 'haywire' which comes from the nature of baling wire to go all sorts of discombobulated, getting tangled and un-spooled and the likes if not properly used/controlled.

So, when something at work goes haywire, you can now picture a bunch of baling wire that has become tangled and sprung off the spool.

Mostly I just wanted to share the origin of 'haywire'. We seem to use the word 'haywire' a lot when referencing computers.
 

Members online


Top