-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplegrep
More file actions
executable file
·41 lines (36 loc) · 847 Bytes
/
applegrep
File metadata and controls
executable file
·41 lines (36 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl -w
# I built the initial list with this: http://www.coffer.com/mac_find/?string=apple
main();
#########################
sub main
{
open(AMACS, "$ENV{HOME}/etc/applemacs.txt") || die "Failed to open sourcefile\n";
my @macs;
while(<AMACS>)
{
/^([0-9A-F]{6})/;
if(defined $1)
{push(@macs, $1);}
}
my @toret;
while(my $line = <>)
{
$line = regularise_inline($line);
if(defined $line)
{
if(grep {$line =~ /$_/} @macs)
{push(@toret, $line);}
}
}
print '#' x 20; print "\n";
print join("\n", @toret) . "\n";
}
sub regularise_inline($)
{ # If the line has what looks like a MAC, convert it to uppercase and remove
# colons from it. Otherwise return undef
my ($in) = @_;
$in =~ tr/://d; # Will chop out other colons. I am okay with that.
$in =~ s/([0-9A-Fa-f]{6})/\U$1\E/g;
#print "Returning $in\n";
return $in;
}