If you have ever used tail to follow multiple files, you will notice that it can be a real pain to read what data is coming from what file. Here is some quick perl I use to make it a bit easier:
|
1 |
tail -f *error_log | perl -pe "s/==>(.*)?<==/\e[0;31m$&\e[0m/g"; |
You can of course extend this to a full out perl script that processes data as follows:
|
1 2 3 4 5 6 7 8 9 10 |
#!/usr/bin/perl // Filename: processor.pl while ($line = <STDIN>) { // Process $line however you need // For the above example... $line =~ s/==>(.*)?<==/\e[0;31m$&\e[0m/g; // Now print it out like a boss print $line; } |
Now you can just pipe whatever data you want into the above script:
|
1 |
tail -f *error_log | perl -p processor.pl |