Perl新手在這裏。我有一個日誌文件,我需要解析出「備份成功」和任何「錯誤:」條目。我嘗試使用unix cat解析日誌文件並將其管道化爲grep。我得到了我想要的信息,但是我想在perl中嘗試這一點,並且還可以選擇傳遞日期參數,並根據我需要的日期給出行。perl幫助根據時間輸入解析日誌文件
示例日誌文件的輸出:(備份成功)日誌文件輸出的
Wed Jun 09 06:14:25 2010: db2.cal.mil.mad:backup:INFO: flush-logs-time=00:00:00
Wed Jun 09 06:14:25 2010: db2.cal.mil.mad:backup:INFO: backup-time=06:14:23
Wed Jun 09 06:14:25 2010: db2.cal.mil.mad:backup:INFO: backup-status=Backup succeeded
Wed Jun 09 06:14:25 2010: db2.cal.mil.mad:backup:INFO: Backup succeeded
樣品:(錯誤:)
Wed Jun 09 05:00:03 2010: rip1.mil.mad:backup:ERROR: mysql-zrm appears to be already running for this backupset
Wed Jun 09 05:00:03 2010: rip1.mil.mad:backup:ERROR: If you are sure mysql-zrm is not running, please remove the file /etc/mysql-zrm/rip1.mail.mad/.mysql-zrm.pid and restart mysql-zrm
**我想文字和/或電子郵件與此信息。像這樣,但可以選擇通過我需要的日期。
Wed Jun 09 05:00:03 2010: rip1.mil.mad:backup:ERROR: mysql-zrm appears to be already running for this backupset
Wed Jun 09 05:00:03 2010: rip1.mil.mad:backup:ERROR: If you are sure mysql-zrm is not running, please remove the file /etc/mysql-zrm/rip1.mail.mad/.mysql-zrm.pid and restart mysql-zrm
Wed Jun 09 06:14:25 2010: db2.cal.mil.mad:backup:INFO: backup-status=Backup succeeded
如果您想爲我提供一些perl代碼和/或想法來開始。我將不勝感激。謝謝。
完美!這很好。正是我需要的。謝謝你的幫助! – jdamae 2010-06-25 03:02:08