Last active
March 18, 2021 14:45
-
-
Save textarcana/3e72a4d6adb05cf57029654347881b73 to your computer and use it in GitHub Desktop.
Profanity search command line tool.
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
#!/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