Skip to content

Commit

Permalink
feat: add subdiff utility (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted authored Jan 15, 2022
1 parent df88868 commit 77cc346
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions subdiff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# useful to diff the contents of 2 SRT subtitle files

if [ ! -s "$1" ] || [ ! -s "$2" ] || [ "$1" == "$2" ]; then
echo "usage: subdiff file1.srt file2.srt"
exit 1
fi

_read_file() {
cat "$1" | rg '[^\d]|^\s*$'
}

diff -u <(_read_file "$1") <(_read_file "$2") | delta -s --wrap-max-lines unlimited

exit 0

0 comments on commit 77cc346

Please sign in to comment.