Last active
December 22, 2023 09:30
-
-
Save kbingham/c96812ed4e6c26f1c0264a022ab91a88 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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