Skip to content

Instantly share code, notes, and snippets.

@serac
Created January 21, 2016 18:54
Show Gist options
  • Save serac/1438222dae0c9de9e1e7 to your computer and use it in GitHub Desktop.
Save serac/1438222dae0c9de9e1e7 to your computer and use it in GitHub Desktop.
Bash script to find files with mixed whitespace (tabs and spaces)
#!/bin/bash
for F in $(find . -type f -print); do
TCOUNT=$(grep -ce '^\t' $F)
SCOUNT=$(grep -ce '^ ' $F)
if [[ $TCOUNT -gt 0 ]] && [[ $SCOUNT -gt 0 ]]; then
echo $F
fi
done
@Nudin
Copy link

Nudin commented Apr 1, 2021

That doesn't work – at least not with gnu grep, maybe on Mac Os or bsd it works. The (gnu) grep default regexp syntax does not know \t, you have to add an additional -P in line 4 to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment