Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Profanity search command line tool.
#!/usr/bin/env bash
set -Eeuo pipefail
profane_regex=$(
perl -e '
use Bad::Words;
my $wordref = new Bad::Words;
my $updated = $wordref->remove(qw(
xxx
));
my $regex = join("|", @$updated);
print qq{\\b($regex)\\b}')
# Mac only allows ~5k open files by default
ulimit -Sn 10000
# Search all files except for binaries. That is what the file/awk
# lines are doing here: filtering out binary files.
# cf https://unix.stackexchange.com/questions/46276/finding-all-non-binary-files
find . \
-not -name "*.min.*" \
-not -name "*bootstrap*" \
-not -name "*jquery*" \
-not -name "*lodash*" \
-type f \
-exec file {} + \
| awk -F: '/ASCII text/ {print $1}' \
| parallel -k -j6 -n 4 -m "ack --group --color --nofilter \"${profane_regex}\"" {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment