@
alphonsez $ find . -name '*.py' | xargs -I{} awk 'BEGIN { has_tab = 0; has_space = 0; }
{
if ($0 ~ /^\t+ / || $0 ~ /^ +\t/) { /* mixed tab and space in one line */
printf "%s: found mixed tab and space\n", FILENAME;
nextfile;
} else if ($0 ~ /^\t/) { /* find tab in one line */
if (has_space == 1 ) {
printf "%s: found mixed tab and space\n", FILENAME;
nextfile;
} else {
has_tab = 1;
}
} else if ($0 ~ /^ /) { /* find space in one line */
if (has_tab == 1 ) {
printf "%s: found mixed tab and space\n", FILENAME;
nextfile;
} else {
has_space = 1;
}
}
}' {}
简单测试过,命令的用法。。感觉比较恶心,不知道有没有方便的方法。。