![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how would you know your server was rebooted 3 times or 5 times | kenshinhimura | AIX | 3 | 01-16-2009 09:52 AM |
| Delete repeated nos in a file | gini | UNIX for Dummies Questions & Answers | 2 | 09-02-2008 03:07 PM |
| matching repeated character | robsonde | Shell Programming and Scripting | 5 | 12-13-2007 05:43 PM |
| Get rid of repeated entries. | jijibabawu | Shell Programming and Scripting | 2 | 10-03-2005 10:17 PM |
| Repeated printF causes annoyance with do | C|[anti-trust] | High Level Programming | 8 | 04-26-2005 02:08 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
how many times does this repeated sequence exist
need a script to determine daily how many times does the below repeated sequence exist in a log file, and if it shows failure to connect in the same file
200 PORT Command successful. 150 Opening BINARY mode data connection for rgr016.daily.0305. 226 Transfer complete. local: rgr016.daily.0306 remote: rgr016.daily.0306 also grep for "Not connected" (trying to confirm consistent daily number of expected transfers, & will want to use this total against list of expected outputted files on another /dir Thanks! log has been set to only keep one day's worth of transfers and will no longer append |
|
||||
|
A better way using perl
========================================= #!/usr/bin/perl -w $PORT=0; $OPEN=0; $TRANS=0; $FAIL=0; unless (open(INPUT, "<test5.txt")) { die ("cannot open input, check permissions\n"); } unless (open(OUTPUT, ">output.txt")) { die ("cannot open output, check permissions\n"); } while ($line = <INPUT>) { if ($line =~ /200/) { $PORT++; } elsif ($line =~ /150/) { $OPEN++; } elsif ($line =~ /226/) { $TRANS++; } elsif ($line =~ /not connected/i) { $FAIL++; } } print OUTPUT "PORT: $PORT\n"; print OUTPUT "OPEN: $OPEN\n"; print OUTPUT "TRANS: $TRANS\n"; print OUTPUT "FAIL: $FAIL\n"; close (INPUT); close (OUTPUT); |
| Sponsored Links | ||
|
|