3

When comparing directories with Meld, it will show the Size column in a "human readable" format, i.e. 4.1 kB. How do I make Meld show me the exact number of bytes, i.e. 41203 bytes?

I am comparing two directories where in some of the cases, the files on the left have 2 or 3 bytes more than the files on the right, while the rest of their content is the same. There are also other types of differences in other files, but then their file size is a lot more different, so they are easy to spot (and ignore). I only want to open the files that are just a few bytes different, to verify them. I don't want to open files that are for example more than 20 bytes different, I don't care about those. But the "human readable" format creates a lot of extra work for me.

Amedee Van Gasse
  • 342
  • 3
  • 17

1 Answers1

0

I think your best option is to use a different tool to identify small size differences. It's relatively easy to write a shell script to that extent:

#!/bin/bash
set -eu
dir1="${1%/}" dir2="${2%/}"
sizedifflimit="${3:-20}"
difftool="${4:-meld}"

find "$dir1" -type f -printf '%s\t%p\0' |
while read -rd '' size1 file1; do
    file="${file1:$((${#dir1}+1))}"
    file2="$dir2/$file"
    size2="$(stat -c '%s' -- "$file2")"
    sizediff=$(($size1 - $size2))
    if [ "$sizediff" -ne 0 -a "${sizediff#-}" -lt "$sizedifflimit" ]; then
        $difftool -- "$file1" "$file2"
    fi
done

Usage:

bash size-diff.sh DIR1 DIR2 [SIZE-LIMIT] [DIFF-TOOL]
David Foerster
  • 36,890
  • 56
  • 97
  • 151