Skip to content

Instantly share code, notes, and snippets.

@robinkaty
Created August 14, 2023 17:40
Show Gist options
  • Save robinkaty/7276b16f2774fe8586e72d82f12f622a to your computer and use it in GitHub Desktop.
Save robinkaty/7276b16f2774fe8586e72d82f12f622a to your computer and use it in GitHub Desktop.
Check Timemachine Output for "0 bytes/sec" and insert error warning into stream/pipe
#!/usr/bin/env perl
use strict;
use warnings;
my $special_string = "0 bytes/sec";
sub process_text_pipe {
my @output;
while (<>) {
my $line = $_;
chomp $line;
if ($line =~ /$special_string/) {
$line .= "\n\n !!!! ERROR ERROR ERROR ERROR !!!!\n";
}
push @output, $line;
}
return @output;
}
my @processed_output = process_text_pipe();
foreach my $line (@processed_output) {
print "$line\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment