Created
January 21, 2016 18:54
-
-
Save serac/1438222dae0c9de9e1e7 to your computer and use it in GitHub Desktop.
Bash script to find files with mixed whitespace (tabs and spaces)
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.