~kris/dots

srice

ref: e9b48d06a8541f3eda5c4db90382ab3c77183afb srice/.local/bin/dups -rwxr-xr-x 484 bytes
e9b48d06 — Kris Yotam xprofile: systemd-aware pipewire start + blueman-applet; sb-internet: tolerate missing /proc/net/wireless 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env perl
# dups -- find duplicate adjacent words
use strict;
my $red = "\033[0;31m";
my $reset = "\033[0m";
my $count = 0;
my $lastword = "";
while (<>) {
    chomp;
    my @words = split /\s+/;
    foreach my $word (@words) {
        my $lc = lc($word);
        $lc =~ s/[^a-z]//g;
        if ($lc eq $lastword && $lc ne "") {
            print "$ARGV:$.: ${red}$word${reset}\n";
            $count++;
        }
        $lastword = $lc;
    }
}
exit ($count > 0 ? 1 : 0);