PodcastsEducationHacker Public Radio

Hacker Public Radio

Hacker Public Radio
Hacker Public Radio
Latest episode

277 episodes

  • Hacker Public Radio

    HPR4657: UNIX Curio #8 - Comparing Files

    09/06/2026
    This show has been flagged as Clean by the host.

    This series is dedicated to exploring little-known—and occasionally useful—trinkets lurking in the dusty corners of UNIX-like operating systems.


    Most users of UNIX-like systems are probably familiar with the
    diff
    utility. It is widely used with source code to compare two files and see what the differences are between them. Non-programmers, like me, also use it to examine what has changed in different versions of scripts or configuration files. Quite a few pieces of newer software can compare different versions of data and express changes in a format either identical to or similar to
    diff
    output.



    However, there are two other long-standing tools for this purpose that are far less known and deserve in my view to be termed UNIX Curios. The first of these is


    cmp




    1
    . While
    diff
    is primarily intended to be used on text files and compares them line by line,
    cmp
    compares files byte by byte. In my experience, its main use is to see whether two binary files are in fact identical—if they are,
    cmp
    outputs nothing and returns an exit status of 0. Back when methods of transferring files were not as reliable as they are today, this was a tool I would reach for sometimes. For example, you could use it to confirm that the data on a CD-ROM you burned was the same as the original.



    If there is a difference between the files,
    cmp
    will return an exit status of 1. By default, it will also print the location (byte and line number) of the first differing byte. When used with the
    -l
    option, it will print the location and value of
    every
    byte that differs. There is one exception to these: if the files are the same except that one is shorter than the other, it will print a message to that effect. The exit status will still be 1 in that case.



    Using the
    -s
    option with
    cmp
    will cause it to be totally silent and output nothing. Only the exit status will indicate whether the files are the same, different, or if the exit status is greater than 1, that an error occurred. This makes it useful for scripting, for example in case you wanted to confirm that a file copied to another location arrived fully intact.



    It is worth noting that
    diff
    is also capable of comparing binary files—however, it is not required by POSIX to report what is actually different or where differences occur. The same exit status as in
    cmp
    is returned: 0 if the files are the same, 1 if they are different, or greater than 1 if an error occurred. While many implementations offer an option to suppress the output,
    this is not in the standard


    2
    so the most portable method would be to instead redirect output to
    /dev/null
    . On my system the
    diff
    utility is three times the size of
    cmp
    , so if you don't need its extra capabilities, it is a less efficient way of doing the job.



    The other UNIX Curio for today is


    comm




    , and this utility


    3
    is also intended to compare two files to see what is common between them. Ken Fallon briefly talked about it a few years ago in
    HPR episode 3889
    . Compared to the others, it has a much more specific use case. The two files are expected to be text files that are already sorted. What
    comm
    will do is print a tab-separated list of all the lines appearing in either or both files. Lines only in the first file will appear in the first column, lines only in the second file will be in the second column, and lines in both files will be in the third column.



    Any combination of the options
    -1
    ,
    -2
    , and
    -3
    can be used with
    comm
    to suppress printing of the first, second, or third column respectively. Using all three options at the same time
    is
    supported but it results in no output, so that isn't very useful. Unlike the other utilities, the exit status of
    comm
    doesn't tell you anything about the two files. It will be 0 if the program ran successfully, and greater than 0 if it didn't.



    I'm not sure if I have ever actually used
    comm
    for anything practical. I find its default output a bit difficult to meaningfully interpret, plus you need to ensure the two files are already sorted. It seems to be best suited to comparing lists, and one use case that Ken Fallon mentioned would be comparing two lists of files to see if any are missing. The command
    comm -3 listA listB
    would print files that only appear in
    listA
    in the first column and those only in
    listB
    in the second column. This would let you ignore all the filenames that appear in both and focus on those that were absent from one or the other. If on the other hand you only wanted to see the filenames that
    are
    on both lists,
    comm -12 listA listB
    would give you that.



    Some more frivolous potential uses also come to mind. If for some reason the
    cat
    utility is broken on your system, you could use
    comm listA /dev/null
    to print the file
    listA
    instead. If you want to insert tab characters before every line of a file but have an aversion to using
    sed
    or
    awk
    , then
    comm /dev/null listA
    would output
    listA
    with one tab before each line, and
    comm listA listA
    would insert two tabs. A bit silly, but it would work. The GNU implementation of
    comm
    even lets you
    choose something other than a tab to separate the columns


    4
    , so you could go wild with that.



    According to the POSIX specifications for
    cmp
    and
    comm
    , one of the two filenames given as arguments, but not both, can be a "
    -
    ", in which case standard input will be used for that "file" in the comparison. Also, the results are undefined if both arguments are the same FIFO special, character special, or block special file. Some implementations might not have these limitations, but you shouldn't rely on that everywhere.



    All three of these were developed quite early. The


    cmp




    utility
    appeared in 1971's First Edition UNIX
    5
    , while


    comm


    and


    diff


    seem to have made their debut in Fourth Edition UNIX
    6,7
    from 1973. The original versions might not have behaved exactly like their modern counterparts, and newer implementations (especially of the
    diff
    utility) have acquired additional options and capabilities, but the basic operation of each has stayed the same.



    The next time you need to compare files against each other, consider whether
    cmp
    or
    comm
    might be appropriate before automatically reaching for
    diff
    . They all have their uses in different situations.



    References:







    Cmp specification
    https://pubs.opengroup.org/onlinepubs/009695399/utilities/cmp.html





    Diff specification
    https://pubs.opengroup.org/onlinepubs/009695399/utilities/diff.html





    Comm specification
    https://pubs.opengroup.org/onlinepubs/009695399/utilities/comm.html





    GNU coreutils manual: comm
    https://www.gnu.org/software/coreutils/manual/html_node/comm-invocation.html





    First Edition UNIX cmp manual page
    http://man.cat-v.org/unix-1st/1/cmp





    Fourth Edition UNIX comm manual page
    https://www.tuhs.org/cgi-bin/utree.pl?file=V4/usr/man/man1/comm.1





    Fourth Edition UNIX diff source
    https://www.tuhs.org/cgi-bin/utree.pl?file=V4/usr/source/s1/diff1.c







    Provide feedback on this episode.
  • Hacker Public Radio

    HPR4656: My review of musicozy sleep/exercise bluetooth headband

    08/06/2026
    This show has been flagged as Clean by the host.


    Sound quality, ease of use, comfort, battery life, price



    https://themusicozy.com/products/headband/index.html
    Provide feedback on this episode.
  • Hacker Public Radio

    HPR4655: Tips for Glasses

    05/06/2026
    This show has been flagged as Clean by the host.

    HPR and Glasses





    HPR community members are nerds



    We know from movies that nerds wear glasses



    We can conclude that HPR community members wear glasses





    Cleaning Background





    I have very oily skin and am constantly smudging my glasses



    All lenses wipes are too small.



    I accidentally touch the lenses with my fingers when I am trying to clean them And smudge them up again



    I heard an eye doctor say, the best way to clean glasses is with dish soap and dry with a microfiber cloth



    I tried this method It is a great solution because you wash glasses and fingers tips at the same time





    Cleaning Method





    Hand soap is OK to use on glasses.



    get the soap on you fingertips



    Then hold your glasses one of the lenses



    Use your thumb and finger tips to clean the glasses



    the soap removes the excess oil from your fingertips



    no smudges when you dry with the microfiber cloth





    Progressives





    With regular progressives the top of the lenses is for distance vision and the bottom of the lenses is for up close vision



    There is a zone in the middle for medium distance, but it is very narrow



    Using a computer at work I kept having to move my head up and down to find the best position for working.



    Computer Glasses have more space for intermediate distances



    From
    https://iotlenses.com/blog/eight-types-of-progressive-lenses.html






    Computer progressive lenses, also known as occupational designs or enhanced readers, are optimized for intermediate and near vision, making them ideal for tasks like prolonged computer work or activities at mid-range distance




    Provide feedback on this episode.
  • Hacker Public Radio

    HPR4654: What's in my component Box?

    04/06/2026
    This show has been flagged as Explicit by the host.

    Background



    This episode describes the contents of an old fishing tackle box I got as a birthday present very many years ago. I used it over the years to gather a pile of mostly useless electronic components and junk.



    I came across it recently when we were doing a clear out. Mrs X wanted to throw it out. I had a lot of sentimental value due to the long time I’ve had it. I am a bit of a hoarder and it took a bit of persuasion on my part to be able to keep it especially since I could not think of a single use for any of the contents!







    I’ve not had time to add links against all the items. Hopefully I’ve managed to add links to most of the more unusual items. Apologies if I’ve missed any.









    Contents of Box













    Top row left to right, back to front







    Compartment 1





    Stereo Jack plug & socket




    Double pole double throw (2-way) switch





    12V dc relay from RS




    3 legged semiconductor (voltage regulator?)







    Compartment 2



    Multiple fuses mostly for cars







    Compartment 3



    Small silica jelly pouch





    Micro Switch






    Reed switches (Not reed relays as I call them in my show)








    Compartment 4



    Potentiometers, Rheostat, variable resistors
    https://en.wikipedia.org/wiki/Potentiometer




    Control knobs







    Compartment 5



    Large selection of miniature panel mounted toggle switches
    https://en.wikipedia.org/wiki/Switch#Toggle_switch








    Compartment 6



    Two crocodile clips
    https://en.wikipedia.org/wiki/Crocodile_clip




    Half of a Hi Fi speaker plug
    https://en.wikipedia.org/wiki/File:Speaker_din_male_and_female.jpg




    Washer







    Compartment 7



    Mostly chocolate block connectors
    https://en.wikipedia.org/wiki/File:Leuchterklemme_75dpi.jpg




    Small selection of glass cartridge Fuses



    Single 13 Amp mains fuse for UK plug



    Assortment of soldering iron tips



    Crocodile clip



    Air adapter for foot pump for blowing up an air bed or similar



    Spare nozzle for a de-soldering tool. Made from PTFE
    https://en.wikipedia.org/wiki/Desoldering#/media/File:Vacuum_plunge.jpg






    https://en.wikipedia.org/wiki/Polytetrafluoroethylene




    Ferrite ring
    https://en.wikipedia.org/wiki/Ferrite_bead








    Compartment 8



    Rubber Grommets and a heatsink











    Middle row left to right, back to front







    Compartment 1



    Large selection of glass cartridge fuses







    Compartment 2



    Another large selection of glass cartridge fuses



    Small selection of diodes, some quite Large
    https://en.wikipedia.org/wiki/Diode








    Compartment 3



    Two multi turn precision variable resistors
    https://en.wikipedia.org/wiki/Potentiometer#/media/File:Beckman_Helipot_potentiometer_SA1400A_2007.075.002.jpg




    Cheap variable resistor with in built switch







    Compartment 4



    Bag of multi coloured LED’s (Cheap for Pi add on board)



    2 inch 8 ohm speaker







    Compartment 5



    Panel mounted heavy duty toggle switch, two pole one way







    Compartment 6



    Light Dependent Resistor (LDR)
    https://en.wikipedia.org/wiki/Photoresistor




    Large Tricolour LED







    Compartment 7



    Variable capacitors PCB (Printed Circuit board) mounted



    Spare nozzle for de-soldering tool. Made from PTFE



    Light Dependent Resistor (LDR)



    Panel mounted heavy duty rotary switch, two pole one way



    Bag of various fuses



    Halogen 12V car headlight bulb



    Variable resistor with long plastic spindle, panel mount



    Heatsink possibly for heavy duty transistor







    Compartment 8



    Variable resistor PCB (Printed circuit board) mounted











    Bottom row



    This is just a big jumble of stuff, listed in no particular order



    DC red and black power lead with inbuilt fuse



    Small solder-less breadboard for prototyping





    https://en.wikipedia.org/wiki/Breadboard




    Bag of various plugs & connectors mostly Jack plugs and sockets



    Bag of quartz crystals and a components receipt from 1985 I added crystals to an old PMR (Private mobile radio) boot mount radio. Possible a Pye Westminster Radio. I looked but couldn’t find picture of the radio



    Several bits of Perfboard or strip board





    https://en.wikipedia.org/wiki/Perfboard




    1 Watt audio amplifier kit with instructions not built!



    D-type serial port mounted to PCB with screw down connections



    Bag of resistors
    https://en.wikipedia.org/wiki/Resistor




    Large bag of LED panel mount holders



    Electronic Instruction guide XH79L (Maplin) price 25p



    Chocolate block connecting block
    https://en.wikipedia.org/wiki/File:Leuchterklemme_75dpi.jpg




    Telephone pickup for recording phone calls. (Never worked)
    https://www.amazon.co.uk/Black-Telephone-Pickup-Sensitive-Microphone/dp/B000L1OZG8




    Multi coloured ribbon cable



    Plastic trimming tool screwdriver set.
    https://www.amazon.co.uk/C-K-T4857-Precision-Plastic-Trimmer/dp/B000WKIYTW




    Panel mounted BNC socket (Baby Neill Constant)





    https://en.wikipedia.org/wiki/BNC_connector








    Provide feedback on this episode.
  • Hacker Public Radio

    HPR4653: Starting the Habit of Reading

    03/06/2026
    This show has been flagged as Clean by the host.

    Openreads is a privacy oriented and open source cross-platform app written in Flutter available for Android and iOS for keeping track of your books.

    There are four lists provided so you won't get confused:

    books you finished,

    books you are currently reading,

    books you want to read later,

    books you didn't finish.

    You can use custom tags and filter through them.

    A book can be added by:

    looking it up in the Open Library database,

    scanning its barcode,

    adding its details manually.

    You can also view some cool statistics!

    Links:

    Battletech: Mercenary's Star by William H. Keith


    Permaculture for the Rest of Us by Jenni Blackmore


    Piranesi by Susanna Clarke


    Battletech: The Price of Glory by William H. Keith


    The Urban Homestead by Kelly Coyne


    Battletech: The Sword and the Dagger by Ardath Mayhar


    Battletch: Warrior En Garde by Michal A. Stackpole


    Sisterhood of Dune by Brian Herbert and Kevin J. Anderson

    Fundamentals of the Wudang Sword Method by Scott M. Rodell


    Battletech: Warrior Riposte by Michal A. Stackpole


    The Cardio Code by Kenneth Jay


    Mentats of Dune by Brian Herbert and Kevin J. Anderson


    How to Grow More Vegtables by John Jeavons

    Provide feedback on this episode.
More Education podcasts
About Hacker Public Radio
Hacker Public Radio is an podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that are of interest to hackers and hobbyists.
Podcast website

Listen to Hacker Public Radio, The Mel Robbins Podcast and many other podcasts from around the world with the radio.net app

Get the free radio.net app

  • Stations and podcasts to bookmark
  • Stream via Wi-Fi or Bluetooth
  • Supports Carplay & Android Auto
  • Many other app features