Show line-by-line differences between two text files using Python's difflib.
A utility skill for comparing two text files and displaying their differences in a readable format. Supports unified diff output and side-by-side comparison modes.
# Show unified diff between two files
python ~/.openclaw/skills/text-diff/text_diff.py unified file1.txt file2.txt
# Show side-by-side comparison
python ~/.openclaw/skills/text-diff/text_diff.py side-by-side file1.txt file2.txt
# Show context diff (3 lines of context)
python ~/.openclaw/skills/text-diff/text_diff.py context file1.txt file2.txt
# Compare with custom context lines
python ~/.openclaw/skills/text-diff/text_diff.py unified file1.txt file2.txt -c 5
unified: Show unified diff format (default)小蔥技能站7w4.net每天更新,海量AI技能等你發現。
context: Show context diff formatside-by-side: Show line-by-line comparison-c, --context: Number of context lines (default: 3)-o, --output: Save diff to file instead of stdout--no-color: Disable colored output# Basic unified diff
python ~/.openclaw/skills/text-diff/text_diff.py unified old.txt new.txt
# Side-by-side comparison with no colors (for piping)
python ~/.openclaw/skills/text-diff/text_diff.py side-by-side old.txt new.txt --no-color
# Save diff to file
python ~/.openclaw/skills/text-diff/text_diff.py unified old.txt new.txt -o diff.txt
# Compare with 10 lines of context
python ~/.openclaw/skills/text-diff/text_diff.py context old.txt new.txt -c 10
--- old.txt
+++ new.txt
@@ -1,5 +1,5 @@
line 1
line 2
-line 3 (removed)
+line 3 (added)
line 4
line 5
OLD | NEW
---------------------------- | ----------------------------
line 1 | line 1
line 2 | line 2
line 3 (removed) | line 3 (added)
line 4 | line 4
0: Files are identical1: Files differ這個 Skill 質量不錯,能比較兩個檔案的差異並顯示出來。文件寫得很清楚,功能也比較實用,支援多種顯示方式,用起來比較方便。唯一的小問題是說明文字中有幾個小錯誤,不影響使用但可以改進一下。整體來說是一個好用的小工具。