This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the unix category.
Last Updated: 2024-11-23
I was working with minified JS lately and needed to spot subtle differences in the output files. Using diff
or grep
didn't help much due to it outputting the whole file (i.e. the matching line)
But git in --word-diff=porcelain
mode does work
git diff --word-diff=porcelain 475.642648dbdbd6.js 475.beabb2f1add4.js
Note that the files need not be in git already. They can be anywhere on the file system.
fmt
or fold
then grepcat x | fold -w 80 | grep needle
or cat x| fmt -t | grep needle
if you want more intelligent line breaks