1

diff has an option --recursive (-r) to do a comparison between two directories (the files inside them). Is there a way to make diff ignore all socket files and only socket files?

I am using diff --brief -r --no-dereference /var/ /media/mateusz/Database/tmp/duplicity_unpack/var/ to verify part of my backup and I am flooded by entries like Only in /var/lib/samba/private/msg.sock: 10001. These files are socket files that Duplicity failed to backup - and it is not indicating a failed backup.

I am aware that I may write my own processing of output but it has potential for bugs, requires more time and requires me to maintain list of socket files in the filesystem.

Note that empty folders should not be ignored in the comparison.

  • If all the socket files are identified by a .sock suffix, then you should be able to exclude them from comparison using a simple glob pattern by adding --exclude='*.sock' – steeldriver Jul 9 '16 at 14:21
  • Unfortunately, most of socket files in my system is not using *.sock extension (and I am not one that controls how filenames were selected) - for example all files in /var/lib/samba/private/msg.sock are composed from numbers and only from numbers. – Mateusz Konieczny Jul 9 '16 at 14:26
  • Sorry, I misread (and didn't check on my own system) that the sockets are numerically named files within a directory called /var/lib/samba/private/msg.sock - I don't understand why you can't simply exclude the directory e.g. --exclude='msg.sock' or --exclude='*.sock' – steeldriver Jul 9 '16 at 15:12
  • @steeldriver Currently I am manually excluding directories, but I would prefer something less prone to failure and requiring less maintenance. – Mateusz Konieczny Jul 10 '16 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.