Skip to content

Instantly share code, notes, and snippets.

@nsdrude
Forked from kbingham/dmesg-diff
Created December 29, 2022 16:06
Show Gist options
  • Save nsdrude/af18133e81fa6d51a4e057efa8580297 to your computer and use it in GitHub Desktop.
Save nsdrude/af18133e81fa6d51a4e057efa8580297 to your computer and use it in GitHub Desktop.
If you need to 'diff' two dmesg files, you will find that the timestamps cause diff-noise. Remove the timestamps so that you get to the underlying diff.
#!/bin/bash
# dmesg-diff
# Kieran Bingham 2016
# Public Domain
#
# Strip out Linux Kernel timestamps when performing a diff on two dmesg files
#
# Initial version as proof-of-concept, but already useful.
# This could be extended to parse extra flags for diff for example
# Uses bash temporary stream extensions to save creating tempory files
# Usage
# dmesg-diff file1 file2
FILE1=$1
FILE2=$2
STRIP_TS='s/^\[[[:space:]+[:digit:].]*\]//'
# http://stackoverflow.com/questions/15841223/diff-while-ignoring-patterns-within-a-line-but-not-the-entire-line
diff -u \
--label=$FILE1 <(sed $STRIP_TS $FILE1) \
--label=$FILE2 <(sed $STRIP_TS $FILE2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment