Skip to content

Instantly share code, notes, and snippets.

@jadonk
Last active October 27, 2020 16:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jadonk/793f0c4f45a53f30bd587f569f4582f7 to your computer and use it in GitHub Desktop.
Save jadonk/793f0c4f45a53f30bd587f569f4582f7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
my $devices = `i2cdetect -y -r 2`;
#print $devices;
my @lines = split /\n/, $devices;
foreach my $line ( @lines ) {
next if $line =~ /^\s/; # skip lines starting with whitespace
$line =~ s/\d\d\:\s*//; # remove 2 digit indexes
#print $line , "\n";
my @entries = split /\s/, $line;
foreach my $entry ( @entries ) {
next if $entry =~ /\-\-/; # skip entries that that are "--"
print $entry , "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment