Every now and then I come across a feature of some Linux command that works so well that I have trouble understanding how I managed without it for so long. The one that I most recently discovered is the side by side option for the diff command.Sure, the designations that diff offers to identify differences between two files are useful. But I don’t find them particularly intuitive. # diff frogs frogs2 7,8c7,8 Florida Cricket Frog > (Acris gryllus dorsalis) 28,30d27 Southern Chorus Frog > (Pseudacris nigrita nigrita) > 35a36,38 > > Little Grass Frog > (Pseudacris ocularis) The standard diff output is meant to be terse. It captures the differences between two files in such a way as to make it possible to convert one file to the other if you only end up with one of them. The “7,8c7,8” string, for example, captures the fact that lines 7 and 8 are different between the two files. If you want to turn frogs into frogs2, you exchange the following two lines with two following the “—“. To turn frogs2 into frogs, you do the reverse. One way to keep many generations of an important file without duplicating most of the content over and over again would to be to save the diffs. If you are only interested in whether the files are different, you can throw away the output from the diff command (i.e., send it to /dev/null) and look at $? (the return code). If the files are different, $? will be set to 1. Alternately, you could use the simpler cmp command which reports the first difference between the two files and then stops. The side by side equivalent of this output is more wordy, but I instantly understand the nature and extent of the differences. The vertical bar (“|”) characters point out differences between the two files while the “” characters note where content appears in only one or the other of the two files. # diff -y -W 80 frogs frogs2 Blanchard's Cricket FrogBlanchard's Cricket Frog (Acris crepitans blanchardi)(Acris crepitans blanchardi) Southern Cricket FrogSouthern Cricket Frog (Acris gryllus gryllus)(Acris gryllus gryllus) Canyon Treefrog| Florida Cricket Frog (Hyla arenicolor)| (Acris gryllus dorsalis) Squirrel Tree FrogSquirrel Tree Frog (Hyla squirella)(Hyla squirella) Green TreefrogGreen Treefrog (Hyla cinerea)(Hyla cinerea) Birdvoiced TreefrogBirdvoiced Treefrog (Hyla avivoca)(Hyla avivoca) Gray TreefrogGray Treefrog (Hyla versicolor - Hyla chrysocelis)(Hyla versicolor - Hyla chrysocelis) Pine Woods TreefrogPine Woods Treefrog (Hyla femoralis)(Hyla femoralis) Northern Spring Peeper Northern Spring Peeper (Pseudacris crucifer crucifer) (Pseudacris crucifer crucifer) Western Chorus Frog Southern Chorus Frog > (Pseudacris nigrita nigrita) > Ornate Chorus FrogOrnate Chorus Frog (Pseudacris ornata)(Pseudacris ornata) > > Little Grass Frog > (Pseudacris ocularis) Cuban TreefrogCuban Treefrog (Osteopilus septentrionalis)(Osteopilus septentrionalis) A diff command with the side by side feature can be added to Solaris systems via the diffutils package (diffutils-2.8.1-sol10-sparc-local.gz). When you want a human-friendly listing of file differences that doesn’t give you anything you will need to decode, this is the command to use. Related content how-to How to find files on Linux There are many options you can use to find files on Linux, including searching by file name (or partial name), age, owner, group, size, type and inode number. By Sandra Henry Stocker Jun 24, 2024 8 mins Linux opinion Linux in your car: Red Hat’s milestone collaboration with exida With contributions from Red Hat and critical collaborators, the safety and security of automotive vehicles has reached a new level of reliability. By Sandra Henry Stocker Jun 17, 2024 5 mins Linux how-to How to print from the Linux command line: double-sided, landscape and more There's a lot more to printing from the Linux command line than the lp command. Check out some of the many available options. By Sandra Henry Stocker Jun 11, 2024 6 mins Linux how-to Converting between uppercase and lowercase on the Linux command line Converting text between uppercase and lowercase can be very tedious, especially when you want to avoid inadvertent misspellings. Fortunately, Linux provides a handful of commands that can make the job very easy. By Sandra Henry Stocker Jun 07, 2024 5 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe